Chinaunix

标题: 请问一个expect+spawn问题 [打印本页]

作者: orablue    时间: 2018-09-03 16:08
标题: 请问一个expect+spawn问题
[root@rac1 rac]# which /usr/bin/expect
/usr/bin/expect
[root@rac1 rac]#


[root@rac1 rac]# cat b.sh
#!/usr/bin/expect
set timeout 10
spawn ssh root@192.168.1.102
expect "password"
send "root123/r"
expect "#"
send "date/r"
expect eof



[root@rac1 rac]# sh b.sh
b.sh: line 3: spawn: command not found
couldn't read file "password": no such file or directory
b.sh: line 5: send: command not found
couldn't read file "#": no such file or directory
b.sh: line 7: send: command not found
couldn't read file "eof": no such file or directory




作者: o枫叶o飘零    时间: 2018-09-03 18:08
   你拿shell去运行expect
#!/usr/bin/expect  既然都写了这个    就直接./执行就好了




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2