From: Glynn Clements <glynn@gclements.plus.com>
To: Freddie <freddie@bulbous.org>
Cc: linux-admin@vger.kernel.org
Subject: Re: Simple expect question
Date: Tue, 14 Nov 2006 11:09:44 +0000 [thread overview]
Message-ID: <17753.41976.755750.365862@cerise.gclements.plus.com> (raw)
In-Reply-To: <13BA4120-D830-478A-8AF6-5EFFA067A6DD@bulbous.org>
Freddie wrote:
> >> 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.
> >
> > The Wikipedia page for Expect uses this task as its first example:
> >
> > http://en.wikipedia.org/wiki/Expect
>
> Thanks, I had already seen that. The problem with the example is it
> expects the username and password as variables that I'd have to give
> on the command line which I'd rather not do.
If you're asking about the prompting, my first attempt would be:
puts -nonewline stderr "Username: "
flush stderr
set username [gets stdin]
puts -nonewline stderr "Password: "
flush stderr
exec stty -echo
set password [gets stdin]
exec stty echo
puts stderr ""
This is just normal Tcl, nothing specific to Expect.
--
Glynn Clements <glynn@gclements.plus.com>
prev parent reply other threads:[~2006-11-14 11:09 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-11-13 14:22 Simple expect question urgrue
2006-11-13 15:05 ` Glynn Clements
2006-11-13 19:28 ` Freddie
2006-11-14 11:09 ` Glynn Clements [this message]
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=17753.41976.755750.365862@cerise.gclements.plus.com \
--to=glynn@gclements.plus.com \
--cc=freddie@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).