Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Responding to prompts via script?

Status
Not open for further replies.

aswolff

Programmer
Jul 31, 2006
100
US
Hi. I need to automate a program which when ran from the command line asks "This will erase all data Continue (y/Y)?"

In a ksh script how can I respond to this prompt with a "y" so that the program will continue running?

Thank you.



 
echo "Continue (Y/N) .\b\c"
read yorn

if [ $yorn = "y" -o $yorn = "Y" ] ; then
echo "Deleting files...."
run something
else
echo "Ok aborting..."
fi


Mike

"Whenever I dwell for any length of time on my own shortcomings, they gradually begin to seem mild, harmless, rather engaging little things, not at all like the staring defects in other people's characters."
 
Re-Read your post (properly)

man expect



Mike

"Whenever I dwell for any length of time on my own shortcomings, they gradually begin to seem mild, harmless, rather engaging little things, not at all like the staring defects in other people's characters."
 
My unix admins suck...no 'expect' on solaris.
 
Perhaps you can specify a -s (silent) or -q (quiet) or some other flag for the program to inhibit the questions from the program?


HTH,

p5wizard
 
Have you tried something like this ?
echo Y | yourProgram

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
no quiet or silent mode. I'll try the echo Y | program


Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top