Hi all,
I am trying to write a program that will automate interactive scripts that use 'pkgadd'. Easily enough I can use 'pkgask' and a response file for most of what I want to do, but unfortunately there are parts of some pkg installations that are configured to only take input from /dev/tty!! Does anyone have any ideas on how I can get around the /dev/tty problem so I can automate it?
You can automate input to terminal by using a series of echo and sleep commands.....(sleep commands are important if some of the commands take time to complete).
Here is an exerpt from a telnet script I wrote that requires terminal input....
(
sleep 2
echo ${FTPid}
sleep 2
echo ${FTPpwd}
sleep 2
echo ${FINDstatement}
sleep 5
exit
) | telnet ${FTPserver}
The cariables are obviously all defined earlier..... so effectively my script is compelting the following commands to terminal
telnet <server>
user_id
password
command (i.e rm *.log)
exit
And there is sleeping between commands to allow the commands to execute before I type type the next. This should allow you to complete what you need.
These have always worked for me...
1) Simple version (singe answer)
echo y | pkgadd SOMEpkg
2) Complex version (one answer per line)
pkgadd SOMEpkg << ANSWERS
y
n
/usr/sbin
whatever...
ANSWERS
*replace SOMEpkg w/ your package name
**replace y, n, /usr/sbin, whatever... w/ your answers