Simple expect question

urgrue <[email protected]>
Newsgroups gmane.linux.admin
Message-ID <[email protected]>
I'm trying to make a simple script that will do with telnet what one can
do with ssh when you do "ssh hostname command". iow:
telnet somehost command

then it should, using expect (presumably), telnet into somehost, prompt
me interactively for the username/password, and after successfully
logging in run the command specified on somehost.

As simple as that sounds, I can't figure it out. I've gotten this far
which is probably done all wrong:

#!/usr/bin/expect

spawn telnet [lrange $argv 0 0\n]  #telnet to host given on command line
expect { "login:"
	#how to prompt user interactively for input here?
        "password:"
	#how to prompt user interactively for input here?
	#somehow check for successful login here
        send "[lrange $argv 1 99]" #send command-line args to host
        send "exit\r"
}



any help appreciated.

-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.