[SLUG] how to get shell script to supply password ?

2005-01-12 Thread Rod Butcher
I need to get my shell script to login to something and then enter a 
password at a prompt.. i.e. unattended operation. I can't get the script 
to feed it the password, it always prompts me.. lets say userid=xx, 
password=yy

xyz login xx
>password :
at this point I  want the shell script to feed it the password yy
I've tried | , < to no avail. Read the manpages. no dice.
pointers greatfully received
thanks, Rod
---
Brought to you by a thunderbird, penguin, gnu and a camel
--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html


Re: [SLUG] how to get shell script to supply password ?

2005-01-12 Thread Robert Thorsby
On 2005.01.12 22:33 Rod Butcher wrote:
I need to get my shell script to login to something and then enter a 
password at a prompt.. i.e. unattended operation. I can't get the 
script to feed it the password, it always prompts me.. lets say 
userid=xx, password=yy

xyz login xx
>password :
at this point I  want the shell script to feed it the password yy
I've tried | , < to no avail. Read the manpages. no dice.
Try:
http://expect.nist.gov/
Robert Thorsby
--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html


Re: [SLUG] how to get shell script to supply password ?

2005-01-12 Thread Ben Stanley
If you can do the logging in part with ssh, then you can configure ssh
not to require passwords by copying a key to the target machine. After
doing that:

[EMAIL PROTECTED] ben]$ ssh [EMAIL PROTECTED]
[EMAIL PROTECTED] ben]$

The details are in the documentation for ssh, but I think that you take
the stuff in ~/.ssh/id_dsa.pub from the machine you are logging in from
and add it into ~/.ssh/authorized_keys2 in the machine you are logging
in to. There may be some option you have to turn on to enable it - I
canĀ“t remember that much. You may also have to cause the keys to be
generated.

Ben.

On Wed, 2005-01-12 at 22:33, Rod Butcher wrote:
> I need to get my shell script to login to something and then enter a 
> password at a prompt.. i.e. unattended operation. I can't get the script 
> to feed it the password, it always prompts me.. lets say userid=xx, 
> password=yy
> 
> xyz login xx
>  >password :
> 
> at this point I  want the shell script to feed it the password yy
> 
> I've tried | , < to no avail. Read the manpages. no dice.
> pointers greatfully received
> thanks, Rod
> ---
> Brought to you by a thunderbird, penguin, gnu and a camel

-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html


Re: [SLUG] how to get shell script to supply password ?

2005-01-12 Thread Angus Lees
At Wed, 12 Jan 2005 22:41:21 +1100, Robert Thorsby wrote:
> On 2005.01.12 22:33 Rod Butcher wrote:
> > I need to get my shell script to login to something and then enter a
> > password at a prompt.. i.e. unattended operation. I can't get the
> > script to feed it the password, it always prompts me.. lets say
> > userid=xx, password=yy
> > xyz login xx
> > >password :
> > at this point I  want the shell script to feed it the password yy
> > I've tried | , < to no avail. Read the manpages. no dice.
> Try: http://expect.nist.gov/

To expand on Robert's answer a little:

Almost all "Password:" prompts are done by talking directly to the
programs "controlling tty".  The intention is precisely to bypass the
normal shell pipeline mechanism and prompt the user, even though the
input/output is doing something else.

Now some programs (like gnupg) will also read the password from some
arbitrary file descriptor when given a suitable command line option -
you can use this to pass in the password from another program.

In the general case, however, your program needs to setup a fake tty
and run the program in that, so that it can catch the password
prompt.  The classic program for doing that is "expect" at the URL
Robert gave you.  These days, most other languages (eg perl, python)
also have some sort of library for doing the same, usually called some
variation on "expect" - so if you are more familiar with a particular
language you might want to use its library.  If you don't feel up to
programming anything, the original expect has a "learning mode" where you
can just do what you want (as a human) and it will watch and generate
an expect script that will duplicate that - its pretty cool.

-- 
 - Gus

-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html


Re: [SLUG] how to get shell script to supply password ?

2005-01-12 Thread Jamie Wilkinson
This one time, at band camp, Rod Butcher wrote:
>I need to get my shell script to login to something and then enter a 
>password at a prompt.. i.e. unattended operation. I can't get the script 
>to feed it the password, it always prompts me.. lets say userid=xx, 
>password=yy
>
>xyz login xx
>>password :
>
>at this point I  want the shell script to feed it the password yy
>
>I've tried | , < to no avail. Read the manpages. no dice.
>pointers greatfully received

The password is being read from a tty, not stdin, so you should use
somethign like expect (if you like to whip yourself) or perhaps the Expect
modules for perl or python may be more palatable.

-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html