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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script not recognizing second prompt... 1

Status
Not open for further replies.

GoneHiking

Technical User
Oct 27, 2006
19
US
Needing some help on an odd problem. A piece of a script I'm working on telnets to a router, then waits for the Username prompt, sends my username, waits for a Password prompt, then sends sends my password. The first part works fine (i.e. it waits for the first prompt, sends my username, then it just sits at the Password prompt.

One thing that might be causing issues is the Password prompt is returned immediately after the username is entered. I'm wondering if it doesn't have time to pickup the Password propmt.

Here's my code snippet:


ZocSend "telnet 10.1.96.13" "^M"

ZocWait "Username:"
ZocSend uname1 "^M"
ZocWait "Password:"
ZocSend pass1 "^M"


Username:
Password:
 
What is Zoc... It is not rexx, none of your snippet is Rexx.


Nic
 
Whoops. My bad. Zoc is a terminal emulation program that support Rexx, and it's own blend of Rexx (Zoc-Rexx).

I ended up talking to a co-worker who uses Zoc quite a bit and he pointed out my problem. I had to put the concatenation symbol in-between the password and the ^M. I don't really know why that made a difference, as the Username got sent just fine. Here's what it looks like now:

ZocWait "Username:"
ZocSend uname1 || "^M"
ZocWait "Password:"
ZocSend pass1 || "^M"
 
GoneHiking said:
I don't really know why that made a difference, as the Username got sent just fine.
To see where the difference is - look at this code:
Code:
pass = "Secret"
str  = pass "^M"
say "str = '"||str||"'"

str  = pass||"^M"
say "str = '"||str||"'"
The output is
Code:
str = 'Secret ^M'
str = 'Secret^M'
As you can see, in the first case the password was concatenated with ^M using space character, i.e. the password followed by space was sent and so it was wrong password.
 
hmmmm. So I guess the router didn't mind seeing the extra space at the end of the username, but it did mind seeing it after the password. You'd think it would have choked on the username, but then again, we're talking Cisco here lol.

Thanks for the explanation mikrom.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top