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

Ah ok, i didn't know you could do that! Good to know.

With a bit of googling, am i right in saying that the correct format would be:

user@localhost> ssh user@remotehost tcsh < shell_script.sh

What if i wanted to set an environment variable first?

Thanks for your reply!

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

    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.

      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)!

      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.

        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