Robert M. Solovay wrote:

>I want to write a program to automate my login process. How do I get the
>program to do the login and then release the terminal for my use.
>
>Explanation: To log in to my berkeley account, I need to use the Opie
>program. This gives me a challenge and I have to run a separate program to
>compute the one time password. I would like to run a program which logs
>in, gets the challenge, computes the response, gives it [so as to log me
>in] and then turns the termianl over to me.
>
>Thanks,
>
>       Bob Solovay
>
>
>
    While I won't go so far as to give example code, I'll recommend you 
take a look at Expect.  This program, built on top of Tcl, is designed 
to do exactly what you want, automate interactive programs.  It allows 
you to invoke external programs, wait to receive a prompt like "login: " 
then send a response.  So you could wait for the login prompt, send your 
username, capture the output and use it to run your password generator, 
then wait for the password prompt and send the generated password. 
 After you've done the automated login, you use the 'interact' function 
to turn over control to you.  I bet you could do it in less than 20 
lines of code.  Check out

    http://expect.nist.gov/

    and start hacking some expect scripts! :)

Kahli

Reply via email to