Jump to content

Bash (Unix shell): Difference between revisions

Line 110: Line 110:


DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
</syntaxhighlight>
==Check if running as sudo==
[https://stackoverflow.com/questions/18215973/how-to-check-if-running-as-root-in-a-bash-script Reference]
<syntaxhighlight lang="bash">
if [ $EUID -ne 0 ]
  then echo "Please run as root"
  exit
fi
</syntaxhighlight>
</syntaxhighlight>