我正在尝试编写脚本以自动登录到服务器,运行几行命令(以安装Anaconda),然后退出。下面的脚本可以很好地执行,直到行DefaultSingletonBeanRegistry registry = (DefaultSingletonBeanRegistry) context.getBeanFactory();
registry.destroySingleton({yourbean}) //destroys the bean object
registry.registerSingleton({yourbeanname}, {newbeanobject}) //add to singleton beans cache
为止,该行起步很好,但突然结束(仅安装了大约10个库之后),而没有给出任何错误消息。是因为this
脚本的超时设置吗?关于如何解决它的任何想法?
expect
其中#!/usr/bin/expect
set f [open "/Users/user1/Downloads/servers.txt"]
set hosts [split [read $f] "\n"]
close $f
set f [open "commands.txt"]
set commands [split [read $f] "\n"]
close $f
foreach host $hosts {
spawn ssh -o StrictHostKeyChecking=no USERNAME@$host;
expect "?assword:"
send "PASSWORD\r"
foreach cmd $commands {
expect "$ "
send "$cmd\r"
}
expect "$ "
send "exit\r"
}
只是服务器列表,而servers.txt
如下:
commands.txt
答案 0 :(得分:0)
期望脚本设置超时= 10自动。因此,您需要使用set timeout 120
或其他任何时间在脚本开头更改超时。