#1
|
|||
|
|||
Problem with running script with Telnet
when running the following script the script sometimes skips ip's. Using connectInTab method instead of connect I realised that it was executing the next iteration of the for-loop before the previous one completed for some items. Why is that?
Sub Main On Error Resume Next Dim response Dim ips Dim ip Dim count set count=0 Dim test 'Array of IPM IPs ips= array("10.227.44.37","10.227.44.40","10.227.44.41") 'Array of IPM Names area=array("Arnos1","Arnos2","Arnos3") 'user input prompt Dim strUserInput strUserInput = InputBox( "Enter the current month and year separated by a '.' Example: 'Mar.2012'" ) 'crt.Screen.Synchronous = True 'Driver. Iterates through all the IPs in the ips array for each ip in ips crt.Session.Connect "/TELNET " + ip 'Creates telnet connection Saver(area(count)) crt.Screen.Send count 'BackUp area(count), strUserInput count= count+1 next End Sub 'performs save action Sub Saver(strMSAN) crt.Screen.WaitForString ">>User name:" crt.Screen.Send "root" & chr(13) crt.Screen.WaitForString ">>User password:" crt.Screen.Send "admin" & chr(13) crt.Screen.WaitForString(strMSAN+">") crt.Screen.Send "en" & chr(13) crt.Screen.WaitForString(strMSAN+"#") crt.Screen.Send "con" & chr(13) crt.Screen.WaitForString(strMSAN+"(config)#") crt.Screen.Send "save" & chr(13) response=crt.Screen.WaitForStrings (chr(123)+" <cr>" & chr(124) & "configuration<K>" & chr(124) & "data<K> " & chr(125) & ":" , strMSAN+"(config)#") If response = 1 Then crt.Screen.Send "configuration" & chr(13) crt.Screen.WaitForString( " ![]() End If End Sub 'performs back-up action Sub BackUp(strMSAN, strUserInput) crt.Screen.Send ("backup configuration tftp 172.20.224.139 config_"+strMSAN+"."+strUserInput+".txt" & chr(13)) crt.Sleep 100 crt.Screen.WaitForString(strMSAN+"(config)#") crt.Screen.Send "quit" & chr(13) crt.Screen.WaitForString(strMSAN+"#") crt.Screen.Send "quit" & chr(13) crt.Screen.WaitForString "Are you sure to log out? (y/n)[n]:" crt.Screen.Send "y" & chr(13) End Sub |
Tags |
connect , telnet |
Thread Tools | |
Display Modes | Rate This Thread |
|
|