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 06-12-2019, 02:30 AM
Freddie Freddie is offline
Registered User
 
Join Date: Jun 2019
Posts: 2
How to move the script to the next step

Good Day,,
Can you assist me with the issue that I am having with my script.

I have a script to log into devices and change passwords for two different accounts. At times, there may be a device ( I use an IP list), that may be offline/no longer on the network, etc. When that happens, the script stops. I then have to go back to the list remove that device then start over. Is there a way for me to tell the script to move to the next line item (instead of cancelling), then send me an email with the failed IPs?

Questions2:
What do I use to add a comment is it this (')?

Here is my script.
Const username = "xxxxx" ' Username to use for login
Const password = "xxxx" ' Password for corresponding user

Const DEVICE_FILE_PATH = "xxxxxx.txt"

Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")

Dim fil
Set fil = fso.OpenTextFile(DEVICE_FILE_PATH)

Dim ip
Dim cnxnString

'On Error Resume Next

While Not fil.AtEndOfStream

ip = fil.ReadLine

'MsgBox "IP address is: " & ip

cnxnString = "/SSH2 /L " & username & " /PASSWORD " & password & " " & ip & " /AcceptHostKeys"

' Connect

crt.Screen.Synchronous = True
crt.Session.Connect cnxnString
crt.Screen.WaitForString ">"

crt.Screen.Send "lock database override" & chr(13)
crt.Screen.WaitForString "> "
crt.Screen.Send "set user admin password" & chr(13)
crt.Screen.WaitForString "New password:"
crt.Screen.Send "XXXXXX" & chr(13)
crt.Screen.WaitForString "Verify new password:"
crt.Screen.Send "XXXXXX" & chr(13)
crt.Screen.WaitForString "> "
crt.Screen.Send "st " & chr(8) & chr(8) & "et expertp" & chr(8) & "-asswo" & chr(8) & chr(8) & chr(8) & chr(8) & chr(8) & "password" & chr(13)
crt.Screen.WaitForString "Enter current expert password:"
crt.Screen.Send "XXXXXX" & chr(13)
crt.Screen.WaitForString "Enter new expert password: "
crt.Screen.Send "XXXXXX" & chr(13)
crt.Screen.WaitForString "Enter new expert password (again): "
crt.Screen.Send "XXXXXX" & chr(13)
crt.Screen.WaitForString "> "
crt.Screen.Send "expert" & chr(13)
crt.Screen.WaitForString "Enter expert password:"
crt.Screen.Send "XXXXXX" & chr(13)
crt.Screen.WaitForString "# "
crt.Screen.Send "exit" & chr(13)
crt.Screen.WaitForString ">"
crt.Screen.Send "save config" & chr(13)
crt.Screen.Send "exit" & chr(13)
crt.Screen.Synchronous = False
crt.Session.Disconnect

Wend

fil.Close

End Sub
Reply With Quote
  #2  
Old 06-12-2019, 08:40 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 3,997
Hi Freddie,

For #1, you will need to setup an array of possible responses and then have the appropriate if/else or Select Case construct to handle those responses.

This concept is illustrated in an example script here.


Look for vPossibleResponses array around line 20.

For #2, yes, a ' is the comment character in VBScript.
__________________
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 04:27 AM.