View Single Post
Old 12-31-2018, 11:21 PM
amy_itx_aps amy_itx_aps is offline
Registered User
Join Date: Dec 2018
Posts: 8
I want a script that reads the ip user password path in the host.txt file. Use ssh2 to log in to the unix host and execute some commands on each host.

Host.txt : oracle oracle /home/oracle/data app app /home/app han han /home/han

like this:
After logging in to, execute cd /home/oracle/data/
Login After successful Execute cd /home/app
After logging in, execute cd /home/app

my vbs scripts

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

'turn on synchronous mode so we don't miss any data
crt.Screen.Synchronous = True
'crt.Screen.Synchronous = True

Sub Main

Set fso = CreateObject("Scripting.FileSystemObject")

Set file = fso.OpenTextFile("ip_uu_pass.txt")
crt.Window.Show 3

Do Until file.AtEndOfStream
line = file.ReadLine
commendAndLog line


End Sub

Sub commendAndLog(line)
' turn off synchronous mode to restore normal input processing

crt.Screen.Synchronous = False

equipmentInfo = Split(line)
ip = equipmentInfo(0)
uname = equipmentInfo(1)
pwd = equipmentInfo(2)

Call crt.Session.Log(False)

crt.Screen.Synchronous = True
crt.session.ConnectInTab "/SSH2 /L "&uname&" /PASSWORD "&pwd&" "&ip

crt.Screen.Send "export TMOUT=86400" & chr(13)
crt.Screen.WaitForString "export TMOUT=86400"

End Sub
Attached Images
File Type: png ssh2_auto_read-ip_user_pass.vbs_red.png (132.7 KB, 150 views)
Attached Files
File Type: txt ip_uu_pass.txt (112 Bytes, 147 views)
File Type: txt ssh2_auto_read-ip_user_pass.vbs.txt (993 Bytes, 156 views)
Reply With Quote