View Single Post
  #1  
Old 12-31-2018, 12:26 AM
amy_itx_aps amy_itx_aps is offline
Registered User
 
Join Date: Dec 2018
Posts: 8
SecureCRT vbs script Read files log in a lot of Unix

The vbs script reads the information in the file and logs in to Unix in bulk.



1. ip_uu_pass_path.txt four columns of information

ip user password path
192.168.80.123 oracle oracle /home/oracle/data
192.168.80.124 app app /home/app
192.168.80.3 han han /home/han

2.ssh2_auto_read-ip_user_pass.vbs

ssh2_auto_read-ip_user_pass.vbs Loop read ip_uu_pass_path.txt login Unix


ssh2_auto_read-ip_user_pass.vbs Script content:

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

'turn on synchronous mode so we don't miss any data
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
crt.screen.send chr(13)


Loop



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)


'login unix
crt.session.ConnectInTab "/SSH2 /L "&uname&" /PASSWORD "&pwd&" "&ip

crt.screen.clear

crt.Screen.Send "pwd" & chr(13)

crt.Screen.Send "clear && pwd && whoami" & chr(13)


End Sub
Reply With Quote