linux下自动ssh到服务器上执行命令
时间:2006-12-30 来源:shinewaysoft
操作系统:linux
说明:使用expect自动输入密码以及要执行的命令
编辑:
[root@Test ssh]# more ssh.sh
#!/usr/bin/ssh
spawn ssh -l root 192.168.0.1 expect "*password:"
send "YOkCq#%M\r"
expect "*#"
send "hostname\r"
expect "*#"
send "pwd;ls -l\r"
expect "*#"
send "exit\r" 执行方法:[root@Test ssh]# expect ssh.sh 扩展:可以根据个人需要加入参数等
#!/usr/bin/ssh
spawn ssh -l root 192.168.0.1 expect "*password:"
send "YOkCq#%M\r"
expect "*#"
send "hostname\r"
expect "*#"
send "pwd;ls -l\r"
expect "*#"
send "exit\r" 执行方法:[root@Test ssh]# expect ssh.sh 扩展:可以根据个人需要加入参数等
相关阅读 更多 +