Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

capturing waitfor to a variable

Status
Not open for further replies.

sonydada

Programmer
Dec 13, 2001
2
US
Hi all,

I am experiencing a problem in handling a procomm aspect script. Basically the script logon to a remote location and downloads a file. In a month's time, the password expires and I have to keep that in a loop.
Eg.
1.waitfor "Username: "
2.transmit "uuuuuuu"
3.waitfor "Password: "
4. transmit "ppppppppp"

5.waitfor "New Password: " }
6.transmit "Nppppppppp" }
7.waitfor " Press any key to continue"

In the above script, either system prompts for either line (5,6,7) or (7). I thought of capturing the waitfor into a local variable and evaluate it
(eg. $localvariable = waitfor
if $localvairable = "New Password"
.......
endif
-------
Working on aspect is completely new to me. So, could anyone throw some limelight on this. Thanks. Sony.
 
There are a couple different ways you could handle this. One would be to leave your script like it but check for success after the waitfor "New Password:" command. If the return code of the waitfor command was success, indicating that the text "New Password:" was found, you could then transmit the new password. It would look something like this:

waifor "New Password:"
if success
transmit "Nppppppppp"
endif
waitfor " Press any key to continue"

Since a waitfor command waits for 30 seconds by default, if the "New Password:" text is not found, then the transmit statement would never be executed. You could reduce the timeout value by placing an integer value (the number of seconds to wait) at the end of the transmit command.

The other way to handle this situation would be to use the when target command. The when target command calls a procedure when the desired text is received by Procomm. This procedure could then transmit the new password, as well as performing any other necessary steps, before returning to the main script. At the beginning of your script, you would put the line:

when target "New Password:" call NewPassword

then after the endproc of your main procedure, you would put:

proc NewPassword
transmit "Nppppppppp"
endproc

The benefit of the when target command in this case is that the NewPassword procedure would only be called if the "New Password:" string appeared. For the waitfor case, you will always have some slight delay while waiting for the "New Password:" string.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top