SecureCRT中用vbs脚本批量执行unix命令 一般登陆上主机后都会敲一些命令了解主机的主要参数,把常用命令集成在一个vbs脚本里, 自动执行,方便高效。

SecureCRT运行方法:菜单栏Script --> 选择Run --> 选择vbs脚本(后面提供Solaris和AIX操作系统的检测脚本)。

检测SUN主机,solaris_info.vbs如下:

#$language = "VBScript" #$interface = "1.0"

Sub Main '清空屏幕 crt.Screen.Send "clear" & chr(13) crt.Screen.WaitForString "$ " '主机名 crt.Screen.Send "hostname" & chr(13) crt.Screen.WaitForString "$ " crt.Screen.Send "domainname" & chr(13) crt.Screen.WaitForString "$ " crt.Screen.Send "uname -a" & chr(13) crt.Screen.WaitForString "$ " '主机启动时间 crt.Screen.Send "uptime" & chr(13) crt.Screen.WaitForString "$ " '主机IP crt.Screen.Send "cat /etc/hosts" & chr(13) crt.Screen.WaitForString "$ " crt.Screen.Send "ifconfig -a" & chr(13) crt.Screen.WaitForString "$ " '主机CPU crt.Screen.Send "isainfo -kv" & chr(13) crt.Screen.WaitForString "$ " crt.Screen.Send "psrinfo -v" & chr(13) '主机内存 crt.Screen.WaitForString "$ " crt.Screen.Send "prtconf | grep Mem" & chr(13) crt.Screen.WaitForString "$ " crt.Screen.Send "swap -s" & chr(13) crt.Screen.WaitForString "$ " 'Oracle环境变量 crt.Screen.Send "grep ^ORACLE_ .profile" & chr(13) crt.Screen.WaitForString "$ " crt.Screen.Send "echo $NLS_LANG" & chr(13) crt.Screen.WaitForString "$ " crt.Screen.Send "echo $TZ" & chr(13) crt.Screen.WaitForString "$ " crt.Screen.Send "echo $PATH" & chr(13) '主机空间 crt.Screen.WaitForString "$ " crt.Screen.Send "df -h" & chr(13) 'Oracle服务 crt.Screen.WaitForString "$ " crt.Screen.Send "tnsping orcl" & chr(13) crt.Screen.WaitForString "$ " crt.Screen.Send "lsnrctl status" & chr(13) crt.Screen.WaitForString "$ " crt.Screen.Send "ps -ef | grep ora_" & chr(13) crt.Screen.WaitForString "$ " crt.Screen.Send "ps -ef | grep LOCAL=NO | grep -v grep | wc -l" & chr(13) End Sub

检测IBM主机,aix_info.vbs如下:

#$language = "VBScript" #$interface = "1.0" Sub Main crt.Screen.Send "clear" & chr(13) crt.Screen.WaitForString "$ " crt.Screen.Send "uname -a" & chr(13) crt.Screen.WaitForString "$ " crt.Screen.Send "uptime" & chr(13) crt.Screen.WaitForString "$ " crt.Screen.Send "ifconfig -a" & chr(13) crt.Screen.WaitForString "$ " crt.Screen.Send "lsdev -C|grep Process" & chr(13) crt.Screen.WaitForString "$ " crt.Screen.Send "lsattr -E -l sys0 -a realmem" & chr(13) crt.Screen.WaitForString "$ " crt.Screen.Send "lsps -a" & chr(13) crt.Screen.WaitForString "$ " crt.Screen.Send "echo $NLS_LANG" & chr(13) crt.Screen.WaitForString "$ " crt.Screen.Send "echo $TZ" & chr(13) crt.Screen.WaitForString "$ " crt.Screen.Send "df -k" & chr(13) End Sub

--End--