Perl Help


New Member
Verified Provider
sub runSsh {
  my $command = shift;
  my $output;

  my $cmdOut = `ssh -o strictHostKeyChecking=no -l $user -i $keyFile $routeServer \"ping -c4\" `;
Any idea why $cmdOut is blank?


vpsBoard Premium Member
It's might be one of those tedious quote level things.

You could try this to get a sense of what exactly is happening:

my $cmdOut = `set -x && ssh -o strictHostKeyChecking=no -l $user -i $keyFile $routeServer \"ping -c4\" 2>&1`;
That will make the shell echo - unfortunately, you'll get that in $cmdOut but at least you can see what it does.


vpsBoard Premium Member
We'll that actually fixed it.
If so then then whatever output you want to grab is actually going to STDERR instead of STDOUT.  That's what 2>&1 does - it says "take whatever is going to file descripter 2 (standard error) and send it to file descripter 1 (standard output) instead" - effectively merging stderr and stdout.

You could probably get rid of the set -x though...that just turns on shell tracing.