The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
script command udi Shell Programming and Scripting 2 09-19-2008 01:15 PM
Q: Recording shell script screen output using "script" command ? lalfonso.gomez Shell Programming and Scripting 4 01-18-2007 06:31 PM
reg script command.... deep UNIX for Dummies Questions & Answers 7 03-30-2005 08:22 AM
Sed Script/Command Help FuzzyNips UNIX for Dummies Questions & Answers 8 10-27-2004 05:09 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 02-15-2008
Registered User
 

Join Date: Apr 2007
Posts: 4
Command taken away from ksh script

Hi,

Any help or suggestions would be most appreciated. I am having problems in the latter end of this ksh script where I will be checking two files. If they exist do nothing otherwise I need to reinitialize the database which resides on o/s Aix 5.3. The problem I am facing is when the reinit command is issued from command line the user needs to manually input y and hit enter ex.(reinitex.pjg) Which takes control away from the script. Is there a solution to script a y with a <enter command> and still maintain control of the script after the reinit is finsihed?

if [[ -e $monShMemFile ]] && [[ -e $vistaFile ]]
then
echo "break out of script"
else
hcidbinit -i
# user needs to enter "y" + enter to reinit database
fi
Attached Images
File Type: jpg reinitex.jpg (6.0 KB, 7 views)
Reply With Quote
Forum Sponsor
  #2  
Old 02-16-2008
System Shock's Avatar
Registered User
 

Join Date: May 2006
Location: Tau Ceti V
Posts: 393
pipe an "echo y" to your command. Like this:
Code:
# cat script
echo " are you sure? "
read ANSWER
case $ANSWER in
     y) echo "executing";;
     n) echo "no way";;
esac

# echo y | script
executing
So your script would look like
Code:
...
echo y | hcidbinit -i
...
Reply With Quote
  #3  
Old 02-16-2008
Registered User
 

Join Date: Apr 2007
Posts: 4
Thank you system shock that worked perfectly. I was able to cancel the command and still continue with the script. I'll test out the actual reinit Monday but in principle that did exactly what I needed. Thanks again for the help.

if [[ -e $monShMemFile ]] && [[ -e $vistaFile ]]
then
echo "break out of script"
else
echo "hcidbinit test"
echo n | hcidbinit -i
echo "**Did this work?**"
fi
Attached Images
File Type: jpg reinitsol.jpg (6.5 KB, 4 views)
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 05:51 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0