我在使用expect 执行sed -i 的时候, 总是报错无法执行, 请大家帮我分析下, 谢谢。具体的语句是这样的, expect "*#" send "sed -i s/SELINUX=enforcing/SELINUX=disabled/g /etc/sysconfig/selinux\r" 提示的错误是这样的 send: spawn id exp6 not open while executing "send "sed -i s/SELINUX=enforcing/SELINUX=disabled/g /etc/sysconfig/selinux\r"" (file "./test.exp" line 14) 请大家帮我看看谢谢
by 人生高地 - 监控及自动化运维技术 - 2012-12-07 16:33:21 阅读(1741) 回复(3)
expect <expect { "*(yes/no)?*" {send -- "yes\r"; exp_continue} "*password:*" {send -- "kjk123\r"} } send "touch a b c d e\r" send "exit\r" ! 为什么 在10.10.17.3 机器上没建立起来呢
以前装的fc4自己在装系统 的过程中装了expect , 现在的系统 没有,只好自己下了装, 装完,装前几次老是出问题,最好装好,担心自己以后忘记了,就写下来在这里 先下载 ,是在 chinaunix下载的 三个包 : tcl8.4.13-src.tar.gz tk8.4.13-src.tar.gz expect-5.37.1.tar.gz 装 tcl .解压就不说了,就 一个 configure 前面加参数 ...
是否能下列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 ...
现在有这样一个需求,ssh nnn@ip 如果远程能登陆就算成功,如果弹出Token: 就记录这个远程ip,放在失败列表里。脚本不知道怎么写。 #!/usr/bin/expect -f set ip [ lindex $argv 0 ] set timeout 6 spawn ssh nnn@$ip -q expect { "*yes/no" { send "yes\r"; exp_continue} "*as*ord:" {send "nnn\r"} warning* {send "exit\n} } send "/sbin/ifconfig eth1\r" send "exit\r" expect ...
expect 学习 example spawn telenet IP expect "login:*" send "user\r" expect "password:*" send "123456\r" sleep 5 send "service XXXXX start" # =>假如这个命令执行时间长,命令结果不知道。不用expect , sleep,能不能用wait等待服务启动完成,再查状态。 wait #<= wait 行吗 send "service XXXXX status" #查服务启动状态 expect eof
expect -c " spawn scp -P $port /root/.ssh/authorized_keys2 /root/wlx/remote_operate.sh root@$ip:/tmp/ expect { \"*yes/no*\" {send \"yes\r\"; exp_continue} \"*password*\" {send \"OL_\"pB%39n3L\r\"} } 报错: root@xxxxxxxxxxxx's password: extra characters after close-quote while executing "send "OL_"pB%39n3L\r"" invoked from within "expect { ...