Search code examples
perlmodulesftpmessage

Perl using Net::SFTP::Foreign get rid of server welcome message


when I connect to a proFTP Server I get the welcome message printed to stdout.

my $sftp = Net::SFTP::Foreign->new($sftserver);

Everything works fine, but how can I get rid of this message?

I don't want to pipe the whole script output to /dev/null and I don't have access to the server's config.

Thanks.


Solution

  • Use the stderr_fh option as documented:

    stderr_fh => $fh

    redirects the output sent to stderr by the SSH subprocess to the given file handle.

    It can be used to suppress banners:

    open my $ssherr, '>', '/dev/null' or die "unable to open /dev/null";
    my $sftp = Net::SFTP::Foreign->new($host,
                                   stderr_fh => $ssherr);