From mboxrd@z Thu Jan 1 00:00:00 1970 From: urgrue Subject: Simple expect question Date: Mon, 13 Nov 2006 16:22:14 +0200 Message-ID: <45587F96.1000409@bulbous.org> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Return-path: Sender: linux-admin-owner@vger.kernel.org List-Id: Content-Type: text/plain; charset="us-ascii" To: linux-admin@vger.kernel.org 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.