| |||||||||||
Re: expect script aborting in the middle. Posted by admin (Graham Ellis), 15 July 2007 Note to future readers ... the original poster has deleted his question ... which leaves this answer looking pretty daft! - I do wish people would think of other before they make changes that confuse the thread!I think you're "send"ing before the incoming string has completed. Rather than expect "word", try doing expect "word: " - otherwise you'll start sending the password before the telnet daemon is ready for it, loose the first few characters, resulting in an incorrect password being received and a host that won't let you log in. P.S. You should do the same thing for the user name, though that may not be critical as you have type ahead buffering - but type ahead buffering rarely works with passwords. Posted by manicisco (manicisco), 15 July 2007 sorry I had to remove my original post as it had the exact username and pwd and the IP address.Below is the more latest script per ur suggestion.But it didnt work.package require Expect set timeout 60 set username ** set password ** set target 172.21.x.x spawn telnet $target expect "name:" exp_send "$username\r" expect "Password:" exp_send "$password\r" expect -re ">" exp_send "show ip route\r" User Access Verification Username: xx Password: hostname removed> C:\Tcl> Appreciate ur time. Posted by manicisco (manicisco), 15 July 2007 I also tried withexpect ">" Posted by admin (Graham Ellis), 15 July 2007 I note that you've removed the training space off the end of my suggestion; does the password prompt that your system issues not have a space? As I recall, your original post (which you have chosen to delete completely!) suggested it did.Posted by manicisco (manicisco), 15 July 2007 I am sorry.i am new here,i didnt see the modify option.Ok let me write the problem description again.My script. ******* package require Expect set timeout 60 set username removed set password removed set target x.x.x.x spawn telnet $target expect "name:" exp_send "$username\r" expect "Password:" exp_send "$password\r" expect ">" exp_send "show ip route\r" Problem ****** Scirpt doesnt execute the "show ip route" command.It just exits out as soon as the password is being accepted. User Access Verification Username: xx Password: hostname> Posted by manicisco (manicisco), 15 July 2007 Hi Graham,I am not sure which space u r talking about.Is it the space before the password? Posted by manicisco (manicisco), 16 July 2007 Graham,I just read ur posting on top.Sorry.I didnt mean to be selfish.I was so scared to see the username and pwd and the IP address on my post.So I removed the post immediately before seeing the modify option. Posted by admin (Graham Ellis), 16 July 2007 on 07/15/07 at 22:34:57, manicisco wrote:
Yes. The space that comes out after the prompt from your remote device, before you send the password back. If you leave it out, you are having your expect program answer the request for the password before the host is ready for the response (and you might have to add in a delay as well, depending on how quickly the host turns around to receive the password). Posted by manicisco (manicisco), 16 July 2007 Thanks for your time and help. A friend of mine helped me to come up with this script.It works fine.package require Expect set username xxx set password xxxxx set target x.x.x.x spawn telnet $target expect -re "name: " exp_send "$username\r" expect -re "Password: " exp_send "$password\r" expect ">" { exp_send "terminal length 0\r" expect ">" { exp_send "show ip route\r" expect ">" exp_send "exit\r" } } Posted by admin (Graham Ellis), 16 July 2007 on 07/16/07 at 06:17:55, manicisco wrote:
I'm glad you're sorted, and glad to see that my suggestion / analysis was the correct one. Posted by manicisco (manicisco), 16 July 2007 sure.thanks for ur time.Appreciate it.This page is a thread posted to the opentalk forum
at www.opentalk.org.uk and
archived here for reference. To jump to the archive index please
follow this link.
|
| ||||||||||
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho |