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 :slight_smile:
Thanks!

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
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

Change first.ksh to:

#!/bin/ksh
! /tmp/second.ksh && exit 1
rm /tmp/list

and change second.ksh to:

#!/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
1 Like