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

dialog to request user name and passwd

Status
Not open for further replies.

awaite

Technical User
Dec 11, 2002
2
US
I am looking for some suggestion on using a dialog popup to request user name and password, then insert them into my script to log into a remote system. Currently I use this and have to manually have users change the 12345 to username and 67890 to their password.

Any suggestion would be great!

proc login
dialnumber TELNET "1.1.1.1"
waitfor "^@login: "
transmit "12345^M"
waitfor "Password: "
transmit "67890^M"
endproc
 
Try this little script out. You may want to add some error checking but I think it should get you started.


#define TRUE 1

proc main

string uName, pWord, sIPAddress
integer Event

dialogbox 0 51 17 232 116 2 "Script Name"
editbox 1 112 13 70 14 uName 15
editbox 2 113 32 68 14 pword 15
pushbutton 4 125 83 52 12 "OK" OK DEFAULT
pushbutton 5 59 83 52 12 "Cancel" CANCEL
text 7 58 34 52 12 "Password -->" right
text 8 50 15 60 11 "User Name -->" right
editbox 3 113 50 68 14 sIPAddress 15
text 9 59 53 52 12 "IP Address -->" right
enddialog


while TRUE
dlgevent 0 Event
switch Event

case 4
login(uName, pWord, sIPAddress)
;call additional procedures here
endcase

case -1
case 5
exitwhile
endcase

endswitch
endwhile

pwexit

endproc

proc login
param string uName, pWord, sIPAddress
string sUserName, sPassWord, sIPAddr

strfmt sIPAddr "%s^M" sIPAddress
transmit sIPAddr
dialnumber TELNET "1.1.1.1"

waitfor "^@login: "
strfmt sUserName "%s^M" uName
transmit sUserName

waitfor "Password: "
strfmt sPassWord "%s^M" pWord
transmit sPassWord

endproc


Good Luck
Matt
 
Just noticed a mistake in the login procedure. It should look like this:

proc login
param string uName, pWord, sIPAddress
string sUserName, sPassWord, sIPAddr

strfmt sIPAddr "%s^M" sIPAddress
dialnumber TELNET sIPAddr

waitfor "^@login: "
strfmt sUserName "%s^M" uName
transmit sUserName

waitfor "Password: "
strfmt sPassWord "%s^M" pWord
transmit sPassWord

endproc


BTW - I typically use the Dial Telnet command I assume the dialNumber will work the same way.

Matt
 
Thanks Matt, This is just what I was looking for.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top