1

I'm trying to use some script variables in a BASH script to make my code clearer.

However, for some reason, my variables are not being expanded/used.

Nothing happens when I use the variable with the full command spelled out

This is the script I made :

command1=$SOMEPATH/abc.sh
command2=$SOMEPATH/def.sh input
command3=$SOMEPATH/ghi

 gnome-terminal                                                                   \
 --tab -t "Server 1"  -e 'bash -c "export BASH_POST_RC=\"$command1\"; exec bash"'  \
 --tab -t "Server 2"  -e 'bash -c "export BASH_POST_RC=\"$command2";  exec bash"' \
 --tab -t "Server 3"  -e 'bash -c "export BASH_POST_RC=\"$command3";  exec bash"'  

Thanks for any tips

1
  • Single quotes prevent expansion of variables. Use double quotes to save blanks: command2="$SOMEPATH/def.sh input"
    – Cyrus
    Dec 31, 2014 at 17:18

1 Answer 1

2

Declare your variables in double quotes

command1="$SOMEPATH/abc.sh"
command2="$SOMEPATH/def.sh input"
command3="$SOMEPATH/ghi"

Hope this helps!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .