I have a small test script as follows;
TESTDIR="$HOSTNAME"
ssh [email protected] "\$TESTDIR"
mkdir -p ~/$TESTDIR/test
exit
the output with bash -x
is;
+ TESTDIR=ndx
+ ssh [email protected] '$TESTDIR'
+ mkdir -p /home/user/ndx/test
+ exit
Yet on the remote server, no directory exists?
The last argument of ssh
is command you want to execute on the remote host:
TESTDIR="$HOSTNAME"
ssh [email protected] "mkdir -p ~/$TESTDIR/test"