Not sure what language you're using, but I'll assume BASH since you've asked about 'whereis' and 'which'. If the file is not located in $PATH, which won't return anything to stdout except a non-zero exit code. You could use that and the BASH special parameter '$?' to determine whether or not the file is in $PATH. Here's a quickie example that may not be 100% correct but gives you an idea:
Code:
#!/bin/bash
echo "What is the program you want to test: "
read APP
which $APP
if [ $? -ne 1 ]; then
printf "The program is in your path.\n"
else
printf "The program is not found in your path!\n"
fi
Bookmarks