Jim Knoble wrote:
Circa 2005-06-01 dixit dan:
: I have a unique situation here. Upon installation of my RPM, I need to
: run a command, that is unable to take command-line arguments, and need
: to "step through" it in order to make some final preperations for my RPM
: installation.
[...]
: So I'm pretty sure, as I said, 'expect' is what I'll need to use in a
: situation like that. I was wondering, however, if anyone else has come
: across a situation like this, and if so, how did you go about doing it?
: Did you use 'expect', or some other utility?
Depends. If the questions are known and unconditional, it's much
simpler to use a simple here document. For example, assume your
script-crippled command, 'somecommand' asks questions like:
Where have you installed the fizzgig?
What is your hostname?
What IP address should the fizzgig listen on?
How many fizzgigs should run?
and, finally:
I am about to configure the fizzgig. Are you sure you want to
continue?
Then you can "script" somecommand as follows:
somecommand <<EOF
/opt/fizzgig
skeksis.example.net
192.0.2.13
999
y
EOF
If you want to get fancy, you can comment your response script:
cat <<EOF |egrep -v '^[ ]*(#.*)?$' |somecommand
# Where have you installed the fizzgig?
/opt/fizzgig
# What is your hostname?
skeksis.example.net
# What IP address should the fizzgig listen on?
192.0.2.13
# How many fizzgigs should run?
999
# Are you sure?
y
EOF
Note that this method is somewhat brittle and doesn't respond well when
differing or modified versions of somecommand ask different questions
(or a different number of them).
Good luck.
Jim -
I think this is exactly what I'm looking for. I was just not certain
that text could be input in that mannerm, using cat.
I'll toy around with it.
THanks again for your time
-dant