Perl 使用 Net::SFTP::Foreign 去除服务器欢迎信息
Perl using Net::SFTP::Foreign get rid of server welcome message
当我连接到 proFTP 服务器时,我收到打印到标准输出的欢迎消息。
my $sftp = Net::SFTP::Foreign->new($sftserver);
一切正常,但我怎样才能摆脱这条消息?
我不想将整个脚本输出通过管道传输到 /dev/null,而且我无权访问服务器的配置。
谢谢。
按照记录使用 stderr_fh
选项:
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);
当我连接到 proFTP 服务器时,我收到打印到标准输出的欢迎消息。
my $sftp = Net::SFTP::Foreign->new($sftserver);
一切正常,但我怎样才能摆脱这条消息?
我不想将整个脚本输出通过管道传输到 /dev/null,而且我无权访问服务器的配置。
谢谢。
按照记录使用 stderr_fh
选项:
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);