原!linux机器 配置自动scp脚本
1.安装相关依赖包
yum install -y tcl tclx tcl-devel
yum -y install expect
2.脚本 scp.sh
#!/usr/bin/expect
#获取输入参数
set f1 [lindex $argv 0]
set f2 [lindex $argv 1]
set dir [lindex $argv 2]
spawn scp /var/log/usermonitor/$f1 :/apprun/test/$dir
expect "*password*"
send "$PASSWD\n"
sleep 1
spawn scp /var/log/usermonitor/$f2 :/apprun/test/$dir
expect "*password*"
send "$PASSWD\n"
sleep 1
expect eof