All of lore.kernel.org
 help / color / mirror / Atom feed
From: urgrue <urgrue@bulbous.org>
To: linux-admin@vger.kernel.org
Subject: Simple expect question
Date: Mon, 13 Nov 2006 16:22:14 +0200	[thread overview]
Message-ID: <45587F96.1000409@bulbous.org> (raw)

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.


             reply	other threads:[~2006-11-13 14:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-13 14:22 urgrue [this message]
2006-11-13 15:05 ` Simple expect question Glynn Clements
2006-11-13 19:28   ` Freddie
2006-11-14 11:09     ` Glynn Clements

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=45587F96.1000409@bulbous.org \
    --to=urgrue@bulbous.org \
    --cc=linux-admin@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.