Execute a script based on status of embedded script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Execute a script based on status of embedded script
# 1  
Old 03-23-2017
Execute a script based on status of embedded script

Hi,
I have 2 scripts, first.ksh and second.ksh and would like first.ksh to run based on response of 'Y/y' received for second.ksh but in my case it continues to execute 'rm /tmp/list' irrespective of response received, below are my scripts with further info,

Hope I'm making sense Smilie
Thanks!

Code:
cat /tmp/first.ksh
#!/bin/ksh
/tmp/second.ksh ###Next step should be executed based on /tmp/second.ksh input value, if 'Y/y' then exit without executing next line else continue.
rm /tmp/list

Code:
cat /tmp/second.ksh
#!/bin/ksh

if [ -f /tmp/list ]
then
   echo "Found LIST..."
   echo "Are these values correct: Enter y/Y for YES to CONTINUE or n/N for NO to exit: \c"
    read ACCEPT
        if [ "$ACCEPT" == "Y" ] || [ "$ACCEPT" == "y" ] ; then
                echo ""
        else
                echo "You have chosen to exit !"
                exit
        fi
else
   echo "LIST does not exist!!"
   exit
fi

# 2  
Old 03-23-2017
Change first.ksh to:
Code:
#!/bin/ksh
! /tmp/second.ksh && exit 1
rm /tmp/list

and change second.ksh to:
Code:
#!/bin/ksh

if [ -f /tmp/list ]
then	echo "Found LIST..."
	echo "Are these values correct: Enter y/Y for YES to CONTINUE or n/N for NO to exit: \c"
	read ACCEPT
	if [ "$ACCEPT" = "Y" ] || [ "$ACCEPT" = "y" ]
	then	exit 0
	else	echo "You have chosen to exit !"
		exit 1
	fi
else	echo "LIST does not exist!!"
	exit 2
fi

This User Gave Thanks to Don Cragun For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need output of script on screen and file with correct return status of the called script.

Hi, I am trying to capture logs of the script in the file as well as on the screen. I have used exec and tee command for this. While using exec command I am getting the correct output in the file but, script output is not getting displayed on the screen as it get executed. Below is my sample... (14 Replies)
Discussion started by: Prathmesh
14 Replies

2. Shell Programming and Scripting

Script will keep checking running status of another script and also restart called script at night

I am using blow script :-- #!/bin/bash FIND=$(ps -elf | grep "snmp_trap.sh" | grep -v grep) #check snmp_trap.sh is running or not if then # echo "process found" exit 0; else echo "process not found" exec /home/Ketan_r /snmp_trap.sh 2>&1 & disown -h ... (1 Reply)
Discussion started by: ketanraut
1 Replies

3. Shell Programming and Scripting

Shell Script for continuously checking status of a another script running in background, and immedia

Hi, I want to write a script which continuously checking status of a script running in background by nohup command. And if same script is not running then immediately start the script...please help.. i am using below command to run script nohup system_traps.sh & but in some... (9 Replies)
Discussion started by: ketanraut
9 Replies

4. Shell Programming and Scripting

Script for HP Embedded Web Server

Hi, In our company we have serveral HP Officejet Pro 8600 N911g printers. I would like to create one addressbook (in CSV format) and import it to all our printers If i go to the settings of my network printer by ip address: /#hId-EmailContacts in my browser I don't see an option ... (0 Replies)
Discussion started by: eclectica1
0 Replies

5. Shell Programming and Scripting

How to get the exit status of a command in nner script to the outer script?

Hi all, I have a shell script inside which i am executing another shell script. In the inner script im executing a command. i want the status of that command in the outer script to perform some validations. How to get its status please help!!1 Im using ksh. (2 Replies)
Discussion started by: Jayaraman
2 Replies

6. Shell Programming and Scripting

Script which takes two inputs based on that execute othe scripts

Hi, I am using solaris 10 bash shell.this might a small script but i am not much familiar with scripting. My requirement here is script should prompt for users two opions like this "please select either any one option makefile or make& build file". if the user selects make file option... (2 Replies)
Discussion started by: muraliinfy04
2 Replies

7. Shell Programming and Scripting

Assigning return value of an embedded SQL in a shell script variable

I've a script of the following form calling a simple sql that counts the no of rows as based on some conditions. I want the count returned by the sql to get assigned to the variable sql_ret_val1. However I'm finding that this var is always getting assigned a value of 0. I have verified by executing... (1 Reply)
Discussion started by: MxC
1 Replies

8. Shell Programming and Scripting

Bourne shell script with embedded Sybase SQL

Hi, I need a simple (as possible) Bourne shell script that takes an input file of adminID's and spits out a list of adminID's and related tradeID's. Both adminID and tradeID are columns in a Sybase database table called "trades", in which they have a one-to-one relationship. adminID is a... (3 Replies)
Discussion started by: chatieremerrill
3 Replies

9. Shell Programming and Scripting

trigger a script based on the run status of another scipt

Im a newbee.. I have a script which runs few times daily. I want to write another script which should pick up the latest log generated from the last run of the first job and trigger a thrid script if the first script runs successfuly. Please help... Cheers (1 Reply)
Discussion started by: Athena
1 Replies

10. Shell Programming and Scripting

Embedded SQL in AWK script

Hi All, Can I use AWK script to read data from Oracle table (some embedded SQL perhaps) The reason for this that I have a data file and I need to do some basic validations of the data in the file with some statistical figures related to the data file that I have stored in a Oracle table. Thanks... (2 Replies)
Discussion started by: 2nilotpal
2 Replies
Login or Register to Ask a Question