原!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 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
标签:脚本,f1,set,argv,expect,lindex,linux,scp 来源: https://www.cnblogs.com/wuyun-blog/p/13389044.html