I use the following variables at the beginning of my Bash script to get such information:
EXECUTED_FROM_DIR=`pwd`
THIS_SCRIPT_DIR=$(cd $(dirname "$0"); pwd)
cd $THIS_SCRIPT_DIR
#Do different tasks here
...
cd $EXECUTED_FROM_DIR
EXECUTED_FROM_DIR=`pwd`
THIS_SCRIPT_DIR=$(cd $(dirname "$0"); pwd)
cd $THIS_SCRIPT_DIR
#Do different tasks here
...
cd $EXECUTED_FROM_DIR
No comments:
Post a Comment