CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Capturing STDOUT from ssh command

 



carmen.arizona
Novice

Mar 13, 2012, 12:43 PM

Post #1 of 3 (2921 views)
Capturing STDOUT from ssh command Can't Post

hello,

I'm trying to code a test that uses an intermediate host to connect to a filer. Basically filers run super stripped down bash, so we're using the host so perl can be used.

i connect to the filer with ssh and run the command, which it returns to the host. Its all good getting that information, but it's storing $result=1, instead of the STDOUT. Tried using $STDOUT as a variable and it was blank.
(the expected result is hidden because it contains a private email address)


Code
my $result= print `ssh $filername $command`; 
my $expectedresult= "######";

if ($result eq $expectedresult)
{
print "Test PASS: $result";
}
else
{
print "Test FAIL Expected: $expectedresult Result: $result";
}


any help here? thanks!Pirate


(This post was edited by carmen.arizona on Mar 13, 2012, 12:45 PM)


BillKSmith
Veteran

Mar 13, 2012, 1:00 PM

Post #2 of 3 (2916 views)
Re: [carmen.arizona] Capturing STDOUT from ssh command [In reply to] Can't Post

You are storing the status returned by the print command. Use:


Code
  

my $result = `ssh $filername $command`;

print $result;

Good Luck,
Bill


carmen.arizona
Novice

Mar 13, 2012, 1:29 PM

Post #3 of 3 (2915 views)
Re: [BillKSmith] Capturing STDOUT from ssh command [In reply to] Can't Post

easy peasy, thanks a million!

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives