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=xxxxxx, password=yyyyyy > > xyz login xxxxxx > > >password : > > at this point I want the shell script to feed it the password yyyyyy > > 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
