LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Problem with auto login using expect (https://www.linuxquestions.org/questions/linux-software-2/problem-with-auto-login-using-expect-749814/)

laginagesh 08-24-2009 05:04 AM

Problem with auto login using expect
 
Hi ,

I have written a script to auto login to a PC.I am calling the script from a C program.

spawn telnet 192.168.2.115
expect "login: "
send "user123\r"
sleep 1
expect "Password: "
send "password123\r"
sleep 1
expect "$ "
send "su\r"
sleep 1
expect "Password: "
send "password321\r"
sleep 1
expect "# "

This script is using to login as a root. But this is some times working and some times failing for login process.
password is printing before expect "Password :" line execution.

Is the problem with the sleep or sequence of commands in the script.

Help me ...

Cheers
Nagesh

jlinkels 08-24-2009 05:51 AM

Put exp_internal 1 at the start of your script and carefully study what is send to and from the telnet host. Most likely will that give you exactly where it goes wrong.

Please surround code samples with [ CODE] [ /CODE] tags, that is the sharp '#' button on the toolbar of the edit window.

jlinkels


All times are GMT -5. The time now is 05:25 AM.