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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

testing help and running program 1

Status
Not open for further replies.

nuser33

Technical User
Jan 11, 2005
2
US
I need assistance with a script. I've tried to my wits end
to search but found no document helpful. I'm trying to set
a script to check and see if a program on a system and if
it is, to use it.

if $PROGRAM

then

exec $PROGRAM

else

echo $PROGRAM not found
 
Depending on the shell you're playing with take a look at type, which or whence in the man pages.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
sorry I was using the bash shell. And I did type "man if" even in ksh and found nothing helpful
 
Try this:
if [ -x FILENAME ]
then
./FILENAME
else
echo "FILENAME not executable"
fi

 
Anyway, as you use the exec builtin:
exec $PROGRAM
echo $PROGRAM not found

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
You could check certain directories that might not be in your $PATH first, then look at 'whereis', 'type' or the other variants listed above.

if [ -x /sbin/swapadd ] ; then
SWAPADD=/sbin/swapadd
else
SWAPADD=`which swapadd`
fi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top