使expect把用find命令找到的文件批量拷贝到远程机器上去: find . -name mail.* | xargs -i expect scp.sh {} expect脚本: #!/usr/bin/expect set timeout 0 set file [lindex $argv 0] spawn scp $file root@192。168。0。1:~/ exec sleep 5 expect "*password: " exec sleep 1 send "1111111\r" interact 脚本单独运行成功,使用find . -name mail.* | xargs -i expect scp.sh {}以后文件考贝失败,请问各位高手问题出在哪...
by freemanxp2005 - Shell - 2008-02-27 16:54:17 阅读(1365) 回复(2)
expect使用很方便,可是每次写脚本的时候都需要不断的expect 、send 我想把命令写到一个文件中去,然后用 for ... read i from file expect "$PROMPT" send $i 这种形式来简化expect脚本的书写,不知道如何实现。
ip1.txt文件内容如下 ip password ip password ip password ip password ip password 怎么把ip 和密码读出来并且访问它 用这段不行 #!/usr/bin/expect -f set file [open ip1.txt r] spawn ssh -p 57891 root@×.×.×.× expect { "*(yes/no)?" {send "yes\r"} "*password:" {send "12345678\r"} } expect "*~]$" while{[gets $file line]>=0} { send "scp -P 57891 root@[lindex $line 0]:./*\[0-9t\].tracert* /home...
#!/usr/bin/expect set router [lindex $argv 0] set passwd_fs [lindex $argv 1] set passwd_en [lindex $argv 2] set ip [lindex $argv 3] spawn telnet $router expect "Password:" send "$passwd_fs\r" expect ">" send "en\r" expect "passwd:" send "$passwd_en\r" expect "#" 我想在这里读入一个文件,文件内容是对路由器的一些操作命令,已事先用别的脚本生成好! 请问应该怎么写?谢谢!
[code]#!/usr/bin/expect -f set timeout -1 set CORE [lindex $argv 1] set NODE [lindex $argv 2] #echo $CORE spawn bash -c "scp -r {$CORE,$NODE} root@10.14.11.67:/rpms/" expect "* password:*" send "123456\r" expect eof [/code] 出现问题就是只有上传$NODE中的文件。这段代码应该如何填写?
我在shell脚本a.sh中调用了expect脚本a.exp,现在需要在a.exp中执行一系列命令,这些命令在一个文件中存储,请问我如何一行一行地读取这些命令? 有没有像shell中的while read line?? thanks
是否能下列x.x.x.x利用變數的方式 讀入例如/ETC/HOSTS 分別登入不同台SERVER 執行COMMAND #!/usr/bin/expect spawn telnet x.x.x.x expect "login:" send "pom\r" expect "Password:" send "123456\r" expect "$" send "cd /home/p ...