Jump to content

Question about delaying Send()


Recommended Posts

Hello to all,

I am trying to automate a log in sequence for my users here at work. The problem that I'm having is related to having different computers with different speeds. I run the following command:

Run('"C:\Program Files\KTC\putty\putty.exe" -load "EPT via Internet"',"C:\Program Files\KTC\putty",@SW_MAXIMIZE)

This starts a a telnet connection using Putty to our software server. The problem occurs in the time it takes for the Putty telnet connection to send the "login as:" prompt, which differs from machine to machine. If I set to sleep for say 3000 before I start sending login info, it works fine on my faster computer, but does not sleep long enough for our slower computers, so the Send begins before the prompt appears.

I've tried the WinWaitActive command, but the Putty window in question "activates" as soon as the script runs the command--I'd like it to wait until the login propmt appears, but can't seem to find a way of doing this.

Any suggestions?

Regards,

David

Link to comment
Share on other sites

Hello to all,

I am trying to automate a log in sequence for my users here at work.  The problem that I'm having is related to having different computers with different speeds.  I run the following command:

Run('"C:\Program Files\KTC\putty\putty.exe" -load "EPT via Internet"',"C:\Program Files\KTC\putty",@SW_MAXIMIZE)

This starts a a telnet connection using Putty to our software server.  The problem occurs in the time it takes for the Putty telnet connection to send the "login as:" prompt, which differs from machine to machine.  If I set to sleep for say 3000 before I start sending login info, it works fine on my faster computer, but does not sleep long enough for our slower computers, so the Send begins before the prompt appears.

I've tried the WinWaitActive command, but the Putty window in question "activates" as soon as the script runs the command--I'd like it to wait until the login propmt appears, but can't seem to find a way of doing this.

Any suggestions?

Regards,

David

<{POST_SNAPBACK}>

i'm not familiar with the putty application in particular, but alot of times with telnet software there is a status bar containing a section that has the cursor position. that's how i time things with the telnet emulator we use at work. assuming you have a status bar that has the cursor position, just find out what position the cursor is at when it's ready for the send, and wait for it with a loop like:

Opt("WinTitleMatchMode",4)
while not $x = StatusbarGetText("putty","",4) = "22, 14"
sleep(100)
wend
Send($login & "{ENTER}" & $pass)

the parameters i used (except the window name) for statusbargettext are the settings for mine, you'll definitely have to confirm the cursor position you're looking for, and the section of the status bar taht it's in. (autoit window info)

Link to comment
Share on other sites

Hello and thanks for the replies,

The SSH session is "required" for this connection by those in charge of the server I'm connecting to, so I'm stuck with it.

The SSH session connects to a UNIX box to run a software package that we use here for just about everything (accounting, cost accounting, production control, etc).

Unfortunately, there's no Putty status bar, so I can't use that to check for the cursur position.

With that in mind, in my Autoit script, I ran the putty session via command line options to load the user name and password. Once the username and password is entered, a "menu" comes up on the UNIX side for the user to select where he/she wishes to go. For us, this is always "2"...But on a slow machine, even the username/password automation wasn't fast enoug and by the time that UNIX menu comes up, the rest of my SEND commands within the AutoIt script have already executed--even with a sleep(2000) delay before sending that "2"...I could increase the delay, but then users with faster machines are held up for no reason.

So in summary, I still can't find a way for the script to pause until that UNIX menu comes up. I've included the code if anyone would like to take a look and offer any advice.

$vuser="xxx"
$spass="xxxxx"
$vpass="xxxxxx"
AutoItSetOption("WinDetectHiddenText",1)

Run('"C:\Program Files\KTC\putty\putty.exe" -load "EPT via Internet" -l '&$vuser&" -pw "&$spass,"C:\Program Files\KTC\putty",@SW_MAXIMIZE)
;WinWaitActive("eptnyc2.enprotech.com - PuTTY","login as:","")
sleep(2000)
Send("2{ENTER}")
sleep(500)
Send($vuser&"{ENTER}")
sleep(500)
Send($vpass&"{ENTER}")
sleep(500)
Send("{ENTER}evep{ENTER}")

Regards,

David

Link to comment
Share on other sites

Hello and thanks for the replies,

The SSH session is "required" for this connection by those in charge of the server I'm connecting to, so I'm stuck with it.

The SSH session connects to a UNIX box to run a software package that we use here for  just about everything (accounting, cost accounting, production control, etc).

Unfortunately, there's no Putty status bar, so I can't use that to check for the cursur position.

With that in mind, in my Autoit script, I ran the putty session via command line options to load the user name and password.  Once the username and password is entered, a "menu" comes up on the UNIX side for the user to select where he/she wishes to go.  For us, this is always "2"...But on a slow machine, even the username/password automation wasn't fast enoug and by the time that UNIX menu comes up, the rest of my SEND commands within the AutoIt script have already executed--even with a sleep(2000) delay before sending that "2"...I could increase the delay, but then users with faster machines are held up for no reason.

So in summary, I still can't find a way for the script to pause until that UNIX menu comes up.  I've included the code if anyone would like to take a look and offer any advice.

$vuser="xxx"
$spass="xxxxx"
$vpass="xxxxxx"
AutoItSetOption("WinDetectHiddenText",1)

Run('"C:\Program Files\KTC\putty\putty.exe" -load "EPT via Internet" -l '&$vuser&" -pw "&$spass,"C:\Program Files\KTC\putty",@SW_MAXIMIZE)
;WinWaitActive("eptnyc2.enprotech.com - PuTTY","login as:","")
sleep(2000)
Send("2{ENTER}")
sleep(500)
Send($vuser&"{ENTER}")
sleep(500)
Send($vpass&"{ENTER}")
sleep(500)
Send("{ENTER}evep{ENTER}")

Regards,

David

<{POST_SNAPBACK}>

what does autoit window info show when the menu is up that you want to interact wtih?
Link to comment
Share on other sites

what does autoit window info show when the menu is up that you want to interact wtih?

<{POST_SNAPBACK}>

Well, that's the problem...the window info only includes the window title, which is always the Putty client title, throughout the entire session. It's a SSH connection to a UNIX server which runs the software we use--and the window info on my end doesn't change.

David

Link to comment
Share on other sites

Well, that's the problem...the window info only includes the window title, which is always the Putty client title, throughout the entire session.  It's a SSH connection to a UNIX server which runs the software we use--and the window info on my end doesn't change.

David

<{POST_SNAPBACK}>

bummer, i was hoping there would be some kind of a status or windowtext change... not sure what to tell you man... you may want to search the forums for putty though, because i know i've seen it mentioned on here a few times and someone else may have posted something helpful to you
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...