Hey guys,
Not to compare FreeBSD to Linux but in Linux one can use the following code in a .sh file to check if it is being run as root, is there a similar solution for FreeBSD i.e. to check if FreeBSD is running the script as root.
/iSh0w
Not to compare FreeBSD to Linux but in Linux one can use the following code in a .sh file to check if it is being run as root, is there a similar solution for FreeBSD i.e. to check if FreeBSD is running the script as root.
Code:
#!/bin/sh
# Init
FILE="/tmp/out.$$"
GREP="/bin/grep"
#....
# Make sure only root can run our script
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 1
fi
/iSh0w