August 4th, 2003, 08:36 AM
I am very new to UNIX scripting and want to do something that I hope is pretty simple ...
Is there any way to allow a UNIX script to execute interactive commands inside a non-unix program? For example, I have a program called 'smart' that is called with the following instruction at the command-line ...
smart inter spec
which then presents a prompt to the user in the form
and the user is expected to enter the next instruction (i.e. n, t or q).
I want to write a script that will execute the first 'smart inter spec' part, which I have, and works fine, and then execute a command at the Smart(ntq?): command prompt, without requiring any user interaction. I suppose in a way, this is similar to the "-f" (force) option on the "mv" command.
Is this at all possible?
Thanks in advance
P.S. For those interested, SMART is an experimental search system used in information retrieval research
August 4th, 2003, 12:50 PM
Unless it was intentionally blocked (eg. with ssh or password this could be the case), you can "pipe" commands to another program and it will treat it like if somebody typed it.
echo -e "t\n" | smart
(the -e tells it to interpret the "\n" which resembles a RETURN)