Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
外壳代码:
~ 猫 test_longin.sh
#!/usr/bin/expect set timeout 120 spawn /usr/bin/ssh fuyou@target.server expect "*assword*" send "fuyou\n" interact
当我输入./test_login.sh时,它可以成功登录目标服务器,但是当我执行ls命令时,控制台不输出任何文本。所以我不能在目标服务器上执行任何命令。交互有问题吗?
./test_login.sh
ls
我认为您应该在发送后期待一些东西,但不要立即使用命令“交互”。
xxx:/home/username/temp # cat t1.exp #!/usr/bin/expect spawn ssh serverx expect "#" send "ls -l\r" expect "#" interact