Hey guys,
I have an interactive script that is quite critical to our production environmentl thus updating it to run non-interactively is not an option.
The script takes a varying number of arguments, which it ques untill user confirm end of data entry
e.g of user input [arguments]:
1
2
y #add another arguments set
3
4
n #this is last set of arguments
y #start processing
the arguments to be passed to the script are in a file. say file.in
i tried using a here-document, but it turns out that you can't put a here-document in a file as i kept getting "terminator not found" error message from ksh
i wanted to run the script like this:
script << here_doc
where here_doc had:
$
arguments
$
it didn't work! as explained above.
now the funny part, if i pass the arguments through a pipe to the script standard input, it works when using echo or print to print the arguments to standard output:
i.e. [Korn shell]
echo "1\n2\nn\ny" | myscript
^^ this works perfectly, my script runs and reads its input from the pipe. print also works as above
but my problem is, i have a file of these arguments that i want the script to sequentially read its input from.
if I use cat, it doesn't not work!!! the script reads NULL in the first variable!!
cat file.in | myscript
the same also happens when I do
myscript < file.in #script reads NULL in first variable
by the way, the script that is trying to run this script is on another machine so it ssh-es to the host machine and run the script. But i don't think this has anything to do with all this.
e.g.
ssh me@remotehost 'myscript'
Can anybody please suggest something to get myscript to read args from a file?
Thanks in advance