Skip to content

Instantly share code, notes, and snippets.

@thiagorider
Created October 11, 2016 12:56
Show Gist options
  • Select an option

  • Save thiagorider/88242eb5262cdf6229395aad19cb2c6a to your computer and use it in GitHub Desktop.

Select an option

Save thiagorider/88242eb5262cdf6229395aad19cb2c6a to your computer and use it in GitHub Desktop.
Check dependencies on executables in a script.
#!/bin/sh
s=0
if [ -x "$(which curl)" ] ; then #This is the best option for checking...
echo "Utility ...... curl [ ok ]"
else
echo "Utility ...... curl [fail]"
s=1
fi
if [ -f "/bin/grep" ] && [ -x "/bin/grep" ] ; then
echo "grep [ ok ]"
else
echo "grep [fail]"
s=1
fi
if [ -f "/usr/bin/expr" ] && [ -x "/usr/bin/expr" ] ; then
echo "expr [ ok ]"
else
echo "expr [fail]"
s=1
fi
if [ -f "/bin/sed" ] && [ -x "/bin/sed" ] ; then
echo "sed [ ok ]"
else
echo "sed [fail]"
s=1
fi
if [ $s -eq 0 ]; then
echo "All requirements are met."
else
echo "Install requirements before proceeding! "
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment