利用expect登录root账户,结果shell也不能继续执行了
#!/bin/sh
expect -c "
spawn su root
expect \"Password:\"
send \"*******\r\"
interact
"
其他shell代码...
其他shell代码...这里不能执行
利用expect登录root账户,结果shell也不能继续执行了
#!/bin/sh
expect -c "
spawn su root
expect \"Password:\"
send \"*******\r\"
interact
"
其他shell代码...
其他shell代码...这里不能执行
我是这么做的,先登陆远程服务器,然后执行删除和重命名操作。
#!/usr/bin/expect -f
set timeout 600
spawn ssh root@xx.xx.xx.xx
expect "*"
send "cd /usr/share/nginx/html\r"
send "rm -rf tkb\r"
send "mv site tkb\r"
interact
1 回答975 阅读✓ 已解决
1 回答705 阅读✓ 已解决
3 回答720 阅读✓ 已解决
1 回答1.5k 阅读
1 回答844 阅读✓ 已解决
2 回答621 阅读✓ 已解决
1 回答682 阅读
其他shell 可以使用在expect中send发送 send \"echo 123;\r\"