Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 05-17-2018, 07:14 AM
Bersy80 Bersy80 is offline
Registered User
 
Join Date: May 2018
Posts: 1
Help with simple script

Hi all

this is my first tentative for script i have realized this script but i have a problem

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

crt.Screen.Synchronous = True

Dim vHosts(1000)

vHosts(0) = "1.249.207.77"
vHosts(1) = "1.249.218.59"
vHosts(2) = "1.249.144.19"
vHosts(3) = "1.249.129.55"
vHosts(4) = "1.249.11.90"
vHosts(5) = "1.249.227.133"
vHosts(6) = "1.249.13.73"
vHosts(7) = "1.249.8.82"
vHosts(8) = "1.249.205.246"
VHosts(9) = ""


For Each strHost In vHosts
If strHost = "" Then Exit For

Dim logfile
logfile = "C:\Users\XXX\Desktop\YYYY-MM-DD-.txt"
g_strLogFileTemplate = Replace(g_strLogFileTemplate, "YYYY-", Year(Date) & "-")
g_strLogFileTemplate = Replace(g_strLogFileTemplate, "-MM-", "-" & (Month(Date)) & "-")
g_strLogFileTemplate = Replace(g_strLogFileTemplate, "-DD-", "-" & (Day(Date)) & "-")
crt.Session.LogFileName = logfile

crt.Screen.WaitForString "$"
crt.Screen.Send "ssh -l User " & strHost & chr(13)
crt.Screen.WaitForString "assword: "
crt.Screen.Send "pa$$word" & chr(13)
crt.Screen.WaitForString ">"
crt.Screen.Send "disp ip int brief" & chr(13)
crt.Screen.WaitForString ">"
crt.Screen.Send "disp startup" & chr(13)
crt.Screen.WaitForString ">"
crt.Screen.Send "disp cell 0/0/0 all" & chr(13)
crt.Screen.WaitForString " ---- More ----"
crt.Screen.Send " save" & chr(13)
crt.Screen.WaitForString " Are you sure to continue?[Y/N]:"
crt.Screen.Send "y" & chr(13)
crt.Screen.WaitForString ">"
crt.Screen.Send "quit" & chr(13)
crt.Screen.WaitForString "$ "
Next


somtimes some IP are unreachable like in this case:

$ ssh 1.249.8.82
ssh: connect to host 1.249.8.82 port 22: Connection timed out
$

i've try many times but i don't understand how to skip the timeout and go to the next host

thanks
Reply With Quote
  #2  
Old 05-17-2018, 08:12 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 3,529
Hi Bersy80,

You will need to have a WaitForStrings() (plural) that can handle all expected/possible prompts. This is exemplified in the RunCommandsOnMultipleHosts... example script in the script sticky here.

If you look starting at line 647, the script author has created an array of the possible prompts. Then on line 659 is the WaitForStrings() call.
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 08:23 AM.