Using local variable on a remote machine

Hi,

I'm writing a korn shell script where the user enters a variable and I have to create a directory remotely which contains the name of that variable.

Example.

print 'Please enter variable:'
read variable
ssh user@host 'mkdir before_$variable;'

Thank you.

try with double quote.

ssh user@host "mkdir before_$variable;"

it does make it read local variables in the ssh command, but I still need it to use other remote variables during the session.

You can escape the remote ones:

i.e.

ssh user@host "mkdir before_$variable; echo \$remote_variable"
1 Like

Thank you. This worked.