linux - Undefined variable in shell script by using ssh -
i use shell script run r program following:
host_list="server@com" directory="/home/program/" ssh -f "$host_list" 'cd $directory && nohup rscript l_1.r> l_1_sh.txt'
but says
directory: undefined variable.
ssh not propagate environment variables. you're setting on environment of local client ssh
program, not on server side. hack, stick inside commands ssh
running remotely, instead of pre-command environment setup.
host_list="server@com" ssh -f "$host_list" 'directory="/home/program/"; cd "$directory" && nohup ...'
here's simpler version of command let test without depending on particular program setup.
ssh localhost dir="/etc"; echo dir "$dir"; cd "$dir" && pwd && ps