File: capture_stderr.pl

package info (click to toggle)
libnet-sftp-foreign-perl 1.73%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 472 kB
  • sloc: perl: 5,377; sh: 48; makefile: 7
file content (24 lines) | stat: -rw-r--r-- 423 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/perl

use strict;
use warnings;

use Net::SFTP::Foreign;
use File::Temp;

my $hostname = shift // 'localhost';

my $ssherr = File::Temp->new or die "tempfile failed";

my $sftp = Net::SFTP::Foreign->new($hostname, more => qw(-v), stderr_fh => $ssherr);

if ($sftp->error) {
  print "sftp error: ".$sftp->error."\n";
  seek($ssherr, 0, 0);
  while (<$ssherr>) {
    print " ssh error: $_";
  }
}

close $ssherr;