secureCRT的登录sudo脚本来源:
http://oracledba.spaces.live.com/blog/cns!57D0C396BA028F14!276.entry
secureCRT的登录sudo脚本
如果你和我一样每天要开很多secureCRT窗口并且需要sudo(或者其他的事情),并且sudo还设置了timeout,那么一定要阅读这篇文章
一开始没每开一个secureCRT窗口总是要重复下面的事情:
sudo su - oracle
Password:
在等待sudo su 的时候经常会timeout,后来到google,baidu上去找自动sudo 的脚本也没有找到,最后还是乖乖的翻secureCRT的help文档解决了这个问题。
在secureCRT安装目录下C:\Program Files\SecureCRT\scripts
打开example1.vbs
修改username 为sudo su - oracle
修改password 为你自己的password
然后在session options里面设置logon script为该文件
最后记得把windows里面的权限设定为尽量小
有时为了登陆现场解决问题,需要绕多台主机才能抵达目的地,敲命令太麻烦,通过以下方式实现自动登陆,并且可以自动执行其它命令。
Session Options - Connection - Logon Scripts - 选上Logon Script并选择自动登陆脚本
Session Options - Connection - Telnet - Hostname - 设置第一台需登陆的主机ip或主机名
自动登陆脚本示例:
http://oracledba.spaces.live.com/blog/cns!57D0C396BA028F14!276.entry
secureCRT的登录sudo脚本
如果你和我一样每天要开很多secureCRT窗口并且需要sudo(或者其他的事情),并且sudo还设置了timeout,那么一定要阅读这篇文章
一开始没每开一个secureCRT窗口总是要重复下面的事情:
sudo su - oracle
Password:
在等待sudo su 的时候经常会timeout,后来到google,baidu上去找自动sudo 的脚本也没有找到,最后还是乖乖的翻secureCRT的help文档解决了这个问题。
在secureCRT安装目录下C:\Program Files\SecureCRT\scripts
打开example1.vbs
#$language = "VBScript"
#$interface = "1.0"
Sub main
' turn on synchronous mode so we don't miss any data
crt.Screen.Synchronous = True
' Wait for a string that looks like "login: " or "Login: "
crt.Screen.WaitForString "ogin: "
' Send your username followed by a carriage return
crt.Screen.Send "username" & VbCr
' Wait for a tring that looks like "password: " or "Password: "
crt.Screen.WaitForString "assword:"
' Send your password followed by a carriage return
crt.Screen.Send "password" & VbCr
' turn off synchronous mode to restore normal input processing
crt.Screen.Synchronous = False
End Sub
#$interface = "1.0"
Sub main
' turn on synchronous mode so we don't miss any data
crt.Screen.Synchronous = True
' Wait for a string that looks like "login: " or "Login: "
crt.Screen.WaitForString "ogin: "
' Send your username followed by a carriage return
crt.Screen.Send "username" & VbCr
' Wait for a tring that looks like "password: " or "Password: "
crt.Screen.WaitForString "assword:"
' Send your password followed by a carriage return
crt.Screen.Send "password" & VbCr
' turn off synchronous mode to restore normal input processing
crt.Screen.Synchronous = False
End Sub
修改username 为sudo su - oracle
修改password 为你自己的password
然后在session options里面设置logon script为该文件
最后记得把windows里面的权限设定为尽量小
有时为了登陆现场解决问题,需要绕多台主机才能抵达目的地,敲命令太麻烦,通过以下方式实现自动登陆,并且可以自动执行其它命令。
Session Options - Connection - Logon Scripts - 选上Logon Script并选择自动登陆脚本
Session Options - Connection - Telnet - Hostname - 设置第一台需登陆的主机ip或主机名
自动登陆脚本示例:
############################################################
#$language = "VBScript"
#$interface = "1.0"
Sub main
' turn on synchronous mode so we don't miss any data
crt.Screen.Synchronous = True
crt.Screen.WaitForString "ogin:"
crt.Screen.Send "test" & VbCr
crt.Screen.WaitForString "assword:"
crt.Screen.Send "testtest" & VbCr
crt.Screen.WaitForString ">>"
crt.Screen.Send "telnet 212.75.30.146" & VbCr
crt.Screen.WaitForString "ogin:"
crt.Screen.Send "test" & VbCr
crt.Screen.WaitForString "assword:"
crt.Screen.Send "haha" & VbCr
'crt.Screen.Send "export TERM=vt100" & VbCr
crt.Screen.Send "ksh" & VbCr
crt.Screen.Send "set -o vi" & VbCr
crt.Screen.Send "stty erase ^H" & VbCr
' turn off synchronous mode for normal input processing
crt.Screen.Synchronous = False
End Sub
############################################################
#$language = "VBScript"
#$interface = "1.0"
Sub main
' turn on synchronous mode so we don't miss any data
crt.Screen.Synchronous = True
crt.Screen.WaitForString "ogin:"
crt.Screen.Send "test" & VbCr
crt.Screen.WaitForString "assword:"
crt.Screen.Send "testtest" & VbCr
crt.Screen.WaitForString ">>"
crt.Screen.Send "telnet 212.75.30.146" & VbCr
crt.Screen.WaitForString "ogin:"
crt.Screen.Send "test" & VbCr
crt.Screen.WaitForString "assword:"
crt.Screen.Send "haha" & VbCr
'crt.Screen.Send "export TERM=vt100" & VbCr
crt.Screen.Send "ksh" & VbCr
crt.Screen.Send "set -o vi" & VbCr
crt.Screen.Send "stty erase ^H" & VbCr
' turn off synchronous mode for normal input processing
crt.Screen.Synchronous = False
End Sub
############################################################
作者:jackxiang@向东博客 专注WEB应用 构架之美 --- 构架之美,在于尽态极妍 | 应用之美,在于药到病除
地址:https://jackxiang.com/post/1752/
版权所有。转载时必须以链接形式注明作者和原始出处及本声明!
最后编辑: jackxiang 编辑于2009-5-5 15:26
评论列表