Hi Monks

I am trying to SSH into a remote machine and execute a shell script. So far I can access the machine and I can run basic administrative commands such as, pwd, ls ,df -h, but when I attempt to use sh, perl, or any of the SGE commands (qsub, qstat) my script fails. Ideally I want to use the SGE commands directly, but I would be happy if I can get a shell script to run and thereby accomplish what I need to do (check status of a job and hopefully one day actually submit a job). Any help is greatly appreciated.

Below is my existing script:

use warnings; use strict; use Perl::Critic; use Net::SSH::Perl; use Net::SSH::Perl::Key::RSA; use Class::ErrorHandler; my $server="400.800.400.800"; #not a real IP address my $port="22"; my $username="snoopy"; #my $command="df -h"; #this worked #my $command="ls"; #this worked #my $command="sh status.sh"; #Received error Use of uninitialized valu +e $stdout in string at ssh.pl #my $command="/usr/bin/sh status.sh"; #Received error Use of uninitial +ized value $stdout in string at ssh.pl #my $command="qstat"; #Received error Use of uninitialized value $stdo +ut in string at ssh.pl line my $command="pwd"; #this worked my $ssh = Net::SSH::Perl->new("$server", protocol=> 2, port=>"$port", +identity_files=>["/location/of/my/identity/files/file"]); $ssh->login($username); my($stdout, $stderr, $exit) = $ssh->cmd("$command"); print "$stdout";

In reply to SSH and Scripting by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.