in reply to Re^4: Advice on running perl program over ssh
in thread Advice on running perl program over ssh

Setting an environment variable:
ssh user@remotehost 'var1=foo var2=bar tcsh' < shell_script.sh

Joining commands:

ssh user@remotehost 'cmd1 && cmd2 && ... & tcsh' < shell_script.sh

Replies are listed 'Best First'.
Re^6: Advice on running perl program over ssh
by Anonymous Monk on Jul 15, 2014 at 17:37 UTC

    (Not OP here.) Variable setting not worky (ssh: OpenSSH_5.3p1; sh: bash variant on CentOS) ...

    cat c ; echo ; ssh user@host 'Q=xir sh' < c echo $Q Q=xir: Command not found.

    ... and do not see it working sans extra work (compared to setting the variable in the script itself).

    salva, if your proposed code worked for you, I would be interested in knowing about your setup to satisfy personal curiosity.

      It works for me:
      $ echo 'echo $FOO' | ssh localhost 'FOO=bar sh' bar

      Probably you have a non POSIX compatible shell like tcsh configured as your login shell.