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

As shown, it is the ssh process which would receive the contents of your shell script.

Is your "shell_script.sh" really a csh script? If so, do consider renaming it to "shell_script.csh" or "shell_script.tcsh" for the sanity of everybody else.

  • Comment on Re^3: Advice on running perl program over ssh

Replies are listed 'Best First'.
Re^4: Advice on running perl program over ssh
by salva (Canon) on Jul 15, 2014 at 09:35 UTC
    The ssh process just forwards the data to the remote process, in this case the shell interpreter. That is the right way to do it.

      That it does (should have tried myself)!

Re^4: Advice on running perl program over ssh
by Amblikai (Scribe) on Jul 15, 2014 at 09:41 UTC

    Ah yes that was a typo on my part. The script has a tcsh ending

    How would i go about setting a variable first? Or more appropriately, what's the syntax for running a command before the shell script?

    Thanks!

      Amblikai:

      Why not set the variable(s) as the first steps in your generated script?

      ...roboticus

      When your only tool is a hammer, all problems look like your thumb.

        Yeah i think that's what i'll do. It was for the DISPLAY variable

        Some of the processes in my generated script(s) bring up this pointless little splash screen

        Is there anyway to suppress this kind of stuff?

        Also, i've had to change my approach somewhat. The generated script was a list of bsub (lsf) commands. But i've been trying to get pre and post processing working with each bsub command and it seems i can't use the -E and -Ep bsub options, they've been disabled by the admin. So i've resorted to generating a separate shell script for each bsub command.

        So i now have about a hundred seperate shell scripts i need to run over ssh! How do i do that with the method discussed?

        Thanks for all your time and replies. Its very much appreciated!

      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

        (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.