[sf-lug] {} vs. (); and expect ...

Michael Paoli Michael.Paoli at cal.berkeley.edu
Thu Aug 28 19:22:37 PDT 2008

> Date: Sun, 24 Aug 2008 08:34:53 -0700
> From: jim <jim at well.com>
> Subject: Re: [sf-lug] how to get a program (e.g. shell script) to log
> 	in:	e.g. respond to the password prompt?
> To: Usr Bin Sh <usr.bin.sh at gmail.com>
> Cc: sf-lug at linuxmafia.com
>    a note to those interested in the syntax: there are
> two parts to the command, the part in parentheses
> preceding the pipe  |  character and the part following.
> the part preceding is all in parentheses, which puts
> the whole sequence of commands in a sub-shell and
> yields their output as input to the pipe to telnet.

Yes, or use {} for logical grouping, including redirection
where desired, and save the overhead of a subshell.
$ { echo foo; date; echo bar; } |
> LC_ALL=C tr '[a-z]' '[A-Z]'
THU AUG 28 19:09:57 PDT 2008
> On Sat, 2008-08-23 at 18:11 -0700, Usr Bin Sh wrote:
>> In bash you can use (and such sequence works for telnet, ftp):
>> theuser=someuser
>> pword=secrect
>> tout=3
>> (sleep ${tout}; echo ${theuser}; sleep ${tout}; echo ${pword}; sleep
>> ${tout}; echo "pwd"; sleep ${tout}; echo "exit") | telnet
>> host.name.com

> Date: Sun, 24 Aug 2008 10:12:19 -0700
> From: "Justin Ryan" <justizin at vongogo.org>
> Subject: Re: [sf-lug] how to get a program (e.g. shell script) to log
> 	in:	e.g. respond to the password prompt?
> To: sf-lug at linuxmafia.com
> It's worth noting that there is a tool specifically for this purpose:
>   expect!
> http://expect.nist.gov/
> I'm actually not versed in expect, but I know when I was in Rackspace
> engineering, expect was used by a friend to automate the installation
> of things like FreeBSD with no automation a la kickstart.  Something
> I've been meaning to learn for a while and actually after looking over
> the docs today I'm thinking about using it as the basis for network
> service check scripts.

Yes, ... that's basically what expect is for.  A tool for automating
interactive text / character based (not particularly suited for GUI)
applications.  It's not about security - there are generally other ways
of doing that and doing it better.

More information about the sf-lug mailing list