SecureCRT中用vbs脚本批量执行unix命令

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 $NLSLANG" & 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--

转载于:https://blog.51cto.com/chaochang/2043866

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值