Perl 使用 Net::SFTP::Foreign 摆脱服务器欢迎消息

标签 perl module sftp 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);

关于Perl 使用 Net::SFTP::Foreign 摆脱服务器欢迎消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50101490/

相关文章:

perl - 是否可以在 Perl 中使用 SSH 私钥对我的数据进行签名?

c - 系统/类型.h : No such file or directory

perl - 执行外部命令时如何在 Perl 中捕获大量 STDOUT 输出

perl - 这个 Perl 语句是什么意思?

mysql - auto_increment没有为主键设置值?

linux -/proc/modules 中模块实例的含义

ruby-on-rails - `dispatch_request' : 在 Net::SFTP.upload 期间没有这样的请求

python - 使用 fabric.operations.put() 创建远程目录

perl - 如何故障转移

linux - 带过滤器的 Rsyslog 加载模块