[code]#!/bin/bash expect -c " set timeout 1200; spawn /usr/bin/ssh 192.168.0.77 df -lh | awk '/sda1/{if ($5>85) system("perl -w ./send.pl");else print "OK"}' expect { \"*yes/no*\" {send \"yes\r\"; exp_continue} \"*password*\" {send \"123456\r\";} } expect eof;"[/code]报错。请求修改。
#!/usr/bin/expect spawn ssh xb@128.1.1.1 expect "*password:" send "111111\r" 为啥运行完之后还在本地机器上没有登陆上去呢,也没有错误显示。 另外如何在expect中加入shell命令呢 比如想在开始加一句 setenv TERM xterm 谢谢
感谢您能抽出时间阅读这个问题 脚本代码如下: #!/usr/bin/expect spawn /data/svn/trunk/application/dataabstract/day/safe1000/md5_cmd_a3a5ac7950bab78ea3a4c9d2bc56e26 expect "passwor" send "keyword\n" expect eof exit 其中 md5_cmd_a3a5ac7950bab78ea3a4c9d2bc56e26 文件中包含了一条 ssh 登录远程服务器命令: ...
先ssh再执行ftp命令
代码段:
...
my $ftpcmd = <
http://bbs.chinaunix.net/viewthread.php?tid=1070390&highlight=ssh+%D7%D4%B6%AF%B5%C7%C2%BC + #!/usr/bin/expect -f set ipaddress [lindex $argv 0] set passwd [lindex $argv 1] set timeout 5 spawn ssh [email=root@$ipaddress]root@$ipaddress[/email] #######Input "yes" when prompt "yes/no"############ expect { "yes/no" { send "yes\r"; exp_continue} "password:" { send "$passwd\r" } } #################...
expect 命令已经安装可以使用scp拷贝文件了,这次想不用输密码就ssh登录 但是遇到问题了 请指教 代码如下: #!/usr/bin/expect -f set passwd abcd spawn ssh [email]root@192.168.80.39[/email] set timeout 30 expect "yes/no" send "yes\r" expect "*password*" send "$passwd\r" 执行完后没有任何结果。
[root@sfdg1 expect]# more exp_ssh.exp #!/usr/bin/expect #exp_internal 1 set user root set ipaddr [lindex $argv 0] set passwd [lindex $argv 1] spawn ssh $user@$ipaddr expect { "*password:" { send "$passwd\r" } } [root@sfdg1 expect]# [root@sfdg1 expect]# ./exp_ssh.exp 192.168.56.120 root spawn ssh [email]root@192.168.56.120[/email] [email]root@192.168.56.120[/email]'s password: [root@sfdg1 ...
用expect写了个脚本,想在远程主机上执行一个脚本,这个脚本执行需要30min; 代码如下: #!/usr/bin/expect -f set ip [lindex $argv 0 ] set timeout 10 spawn ssh test@$ip expect { "*yes/no" { send "yes\r"; exp_continue} "*assword:" { send "$password\r" } } expect "]$" send "ls\r" expect "]$" send "chmod +x run.sh\r" expect "]$" send "./run.sh\r" expect "]$" send "exit\r" expec...
用expect实现自动ssh登录,不过有个问题目前没有搞明白,用ssh name@host 登录, 有两种情况 第一种:如果是第一次会有一个 The authenticity of host '192.168.10.23 (192.168.10.23)' can't be established. RSA key fingerprint is 54:e6:ce:7a:aa:c0:95:31:58:0d:56:f6:ee:b5:8a:14. Are you sure you want to continue connecting (yes/no)? 的提示,点YES后,然后输入密码. 第二种:ssh 主机直接出输入密码的提示 在expect中如何对这...
:dizzy: 错误信息:sshAuthenticationError Login timed out. The input stream currently has the contents bellow: at /usr/lib/perl5/site_perl/5.8.8/expect.pm line 828 代码[code]#!/usr/bin/env perl use Net::ssh::expect; use strict; my $i; my $command=$ARGV[1]; for($i=0;$i<$ARGV[0];$i++){ my $ip=$ARGV[$i+2]; print $ip; my $ssh=Net::ssh::expect->new( host => $ip...