View Single Post
  #1  
Old 02-11-2020, 08:33 PM
GODWIN1989 GODWIN1989 is offline
Registered User
 
Join Date: Feb 2020
Posts: 2
Python Loop failed for device login in Secure CRT

Hi,
I have below code to read list devices name from text file and list of password(RSA keys) from another text file. However the code gets executed only for first time and not looping through. Not sure if I am missing something in 'WaitFor' function.

Code:
# $language = "python"
# $interface = "1.0"

x=open(r"C:\Users\god\Desktop\device.txt","r")
y=open(r"C:\Users\god\Desktop\pass.txt","r+").readlines()
z=''
a=0
for i in x:
    z=y[a]
    crt.Screen.Send("ssh %s" %(i))
    crt.Screen.WaitForString("word:")
    crt.Screen.Send(z)
    crt.Screen.WaitForString("#")
    crt.Screen.Send("sh clock\n")
    crt.Screen.Send("exit\n")
    a+=1

Last edited by jdev; 02-12-2020 at 09:25 AM. Reason: wrap code in [code][/code] blocks for easier viewing
Reply With Quote