Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Notices

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 02-04-2019, 09:13 AM
rleon rleon is offline
Registered User
 
Join Date: Jan 2008
Posts: 116
Help with timeout

hi

my script is pretty much working except for the time out

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

def main():
        crt.Screen.Synchronous = True
with open('/Path/to/file/hosts2') as hosts_:
        for host in hosts_:

                crt.Screen.WaitForString("nfs]# ")
                crt.Screen.Send("ssh -oStrictHostKeyChecking=no root@" + host + '\r')
                crt.Screen.WaitForString("word: ")
                crt.Screen.Send("Mypassword" + chr(13))

                szOutput = crt.Screen.ReadString(["# ","word:","ssh: "], 10)
                #szOutput = crt.Screen.WaitForStrings(["]# ","word:","nfs2 # "], 3)
                index = crt.Screen.MatchIndex

                if(index == 0):
                        crt.Screen.Send("echo timeout0" + chr(13))

                elif(index == 1):
                        crt.Screen.Send("mount /rhelrepo;subscription-manager clean;/rhelrepo/scripts/rleon_fix.sh" + chr(13))
                        crt.Screen.WaitForString("]# ")
                        crt.Screen.Send("exit" + chr(13))

                elif(index == 2):
                        crt.Screen.Send("Password2" + chr(13))
                        crt.Screen.WaitForString("]# ")
                        crt.Screen.Send("mount /rhelrepo;subscription-manager clean;/rhelrepo/scripts/rleon_fix.sh" + chr(13))
                        crt.Screen.WaitForString("]# ")
                        crt.Screen.Send("exit" + chr(13))

                elif(index == 3):
                        crt.Screen.Send("echo timeout" + chr(13))
     
                else:
                        crt.Screen.Send("echo timeout" + chr(13))


main()
I am able to attend the 2nd password if the 1st one fails.

But if the host does not connect or can not resolve and falls back to the prompt

Code:
nfs]#
then it does nothing.

I tried in several sections and the timeout just doesnt continue.

I am also not able to echo the hostname into the error file.

Code:
crt.Screen.Send("echo" + host + ">> error" + '\r')
I am missing something .. but i cant figure out it.

Any help or ideas are welcome.

Last edited by ekoranyi; 02-04-2019 at 09:31 AM.
Reply With Quote
 

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 03:48 PM.