想搞一个使用ssh登录批量ip地址执行命令,自动输入密码的脚本,但是ssh不能使用标准输入来实现自动输入密码,于是了解到了expect这个可以交互的命令 是什么 查看使用man查看expect,是这么说的,使用谷歌翻译一下 Expect is a program that "talks" to other interactive programs according to a script. Following the script, Expect knows what can be
expect自动远程拷贝脚本,利用rsync命令,脚本内容如下: #!/usr/bin/expect -- proc Usage_Exit {self} { puts "" puts "Usage: $self ip user passwd port sourcefile destdir direction bwlimit timeout" puts "" puts " sourcefile: a file or directory t