Amblikai has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks, just looking for advice on whats the best approach to take with a particular problem.

Basically i write and run all my perl on a local machine where i can install cpan modules etc. I could in theory install them on the remote account but its not an approach i want to take, i'll spare you the boring details

So at the moment i have a perl program which generates a shell script. I then sftp this script to the remote machine (an lsf) and i execute it there.

I'd like to make this a single step. Is there an good way of doing this or should i just keep the original steps and put them in a script on the local machine

  • Comment on Advice on running perl program over ssh

Replies are listed 'Best First'.
Re: Advice on running perl program over ssh
by salva (Canon) on Jul 15, 2014 at 08:46 UTC
    Most shells (all?) can read the script from the stdin stream.

      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!

        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.

Re: Advice on running perl program over ssh
by vinoth.ree (Monsignor) on Jul 15, 2014 at 05:30 UTC
    I then sftp this script to the remote machine

    sftp what the perl program or the shell script which your perl program generates ?


    All is well

      Isn't that exactly what they say they're doing?

      "I then sftp this script to the remote machine (an lsf) and i execute it there"

      Yes it's the generated script. Thanks.