Command taken away from ksh script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Command taken away from ksh script
# 1  
Old 02-16-2008
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
Command taken away from ksh script-reinitexjpg
# 2  
Old 02-16-2008
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
...

# 3  
Old 02-16-2008
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
Command taken away from ksh script-reinitsoljpg
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with ksh Script not resolving '@' in ls command

Hi all, We've been trying to find a way to get a command to work within a ksh with no success. We are attempting to list various files with different hlq's like this ls $FileDir/dir/subdir/${triggers} The $FileDir is set in the script. The $triggers resolves to... (11 Replies)
Discussion started by: Grueben
11 Replies

2. Shell Programming and Scripting

ksh script find command not printing any results

Hello, Hitting a wall on this one. When at the command prompt it works fine: # find /home/testuser -name 'PAINT*canvasON.txt' /home/testuser/PAINT_canvasON.txt # pwd /home/testuser # ls -l PAINT*canvasON.txt -rw-r--r-- 1 root user 23 Feb 07 02:58 PAINT_canvasON.txt... (2 Replies)
Discussion started by: seekryts15
2 Replies

3. Shell Programming and Scripting

Help with command in ksh script

I want my script to check directories and files within the directories older than 7days lold and remove them but the script only removes the directories older than 7 days. find home/prod/clt/nal/inb -mtime +7 -exec rm -rf {} \; The inb contains multiple directories that contain... (2 Replies)
Discussion started by: Bperl1967
2 Replies

4. Shell Programming and Scripting

KSH Script to Execute command from specific column in file

Hi Unix Experts,Team I have a file (say comand_file.prm), The file has a command specified in column 6 (say "./execute_script.sh"). I want to execute this command in my script. I am writing a KSH script to achieve this. Could you please assist me with this. (6 Replies)
Discussion started by: Jeevanm
6 Replies

5. Shell Programming and Scripting

AIX .ksh script freezes when using the mail -s command

Hello I am trying to send an email when a .KSH script is run on an AIX Machine. This email will only include a subject line that is made up of variables from within the script, and is as follows: CURRENT_DATE=`date +%Y%m%d` TIME=`date` ADMIN="myname@domain.com" date block () { ... (4 Replies)
Discussion started by: jimbojames
4 Replies

6. UNIX for Advanced & Expert Users

Running ksh script from command line

Hi. I have a ksh script I want to run, but I'm connecting through a telnet and I don't want to FTP the scripts itself. is there a way of running the script from command line ? like ksh "The script itself..." Thanks, Ramon (4 Replies)
Discussion started by: mellowcandle
4 Replies

7. Shell Programming and Scripting

problem with KSH script: command line args

Hi I am executing a KSH script by passing command line arguments example: Red Green Dark Red Blue when I am splitting the arguments by using " "(Space) as delimiter But the colour Dark Red is a single parameter. But it is getting splitted in between How to avoid this. Please help Also... (4 Replies)
Discussion started by: hemanth424
4 Replies

8. Shell Programming and Scripting

KSH script: piping passes command-line arguments

Dear forum I have the following small script: #!/bin/ksh echo -e "abba-o" | awk -F '-' '{ print $2 }' | cut -b 1It needs to be ksh.. in bash I don't have this problem. If I run this on opensuse 10.2 I get this as output: e If I run this on suse enterprise 10 sp2 then I get this: o ... (1 Reply)
Discussion started by: gemtry
1 Replies

9. Shell Programming and Scripting

ssh command in ksh script encounters permission error

I've created a script and copied it to another server and try to execute it at the same time but I'm getting a permission error. I'm logged on as root and I gave the file 777 permission when I created it, but I can't run it remotely via ssh command because of permission issue. Any ideas? ... (5 Replies)
Discussion started by: pdtak
5 Replies

10. Shell Programming and Scripting

#!/usr/bin/ksh Command Interpreter in a sh script

Hi, I have a developer that is trying to start a script with sh "scriptname". In the script, he is specifying #!/usr/bin/ksh as the command interpreter. For some reason sh is ignoring the #!/usr/bin/ksh. We are running Solaris 8. Does anyone have any ideas what could be causing this? Here... (3 Replies)
Discussion started by: ckeith79
3 Replies
Login or Register to Ask a Question