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

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!

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

Replies are listed 'Best First'.
Re^5: Advice on running perl program over ssh
by roboticus (Chancellor) on Jul 15, 2014 at 12:47 UTC

    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!

        Is there anyway to suppress this kind of stuff?

        There is not a unique right solution for that. Some programs allow to disable their splash screen using some flag on the command line or from the configuration file.

        You can run Xvfb and set is as the target X server.

        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?

        Have you considered using some module like Net::OpenSSH?

Re^5: Advice on running perl program over ssh
by salva (Canon) on Jul 15, 2014 at 14:59 UTC
    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.

        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.