penguins_rule
asked on
bash script to expand variables
in a bash script, the user keys in a command with arguments
some of the arguments are variables defined in the bash profile
i need to run the command they enter
How does the script get the information and then does the whole command?
in the bash profile
export TESTING=/home/programming
in the script, the user keys in: cd $TESTING/penguins
the script needs to: cd /home/programming/penguins
I am running RedHat EL 6.4
some of the arguments are variables defined in the bash profile
i need to run the command they enter
How does the script get the information and then does the whole command?
in the bash profile
export TESTING=/home/programming
in the script, the user keys in: cd $TESTING/penguins
the script needs to: cd /home/programming/penguins
I am running RedHat EL 6.4
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
in my case, i am using the script to make sure they can only type in certain commands. Otherwise, i agree, it would be dangerous.
In the script you can use variables by using $VARIABLE_NAME or ${VARIABLE_NAME} in your case $TESTING or ${TESTING}
By doing: cd $TESTING/penguins in the script it is in fact doing: cd /home/programming/penguins
So looks OK to me ;)