标签:install moni spawn bin pru set sleep exp use
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 USER@IP:/apprun/test/$dir
expect "*password*"
send "$PASSWD\n"
sleep 1
spawn scp /var/log/usermonitor/$f2 USER@IP:/apprun/test/$dir
expect "*password*"
send "$PASSWD\n"
sleep 1
expect eof
标签:install moni spawn bin pru set sleep exp use
原文地址:https://www.cnblogs.com/wuyun-blog/p/13389044.html