【发布时间】:2020-11-06 02:13:25
【问题描述】:
在调用$sftp->disconnect() 时,连接没有关闭,Perl 脚本处于挂起状态,直到我手动终止进程。
以下是我们如何创建 SFTP 连接的代码:
my %sftp_args = ( user => $username, autodie => 1, stderr_discard => 1,more => qw(-v),
timeout => $timeout_secs,ssh_cmd => $SSH_PATH );
my $sftp = Net::SFTP::Foreign->new($remote_host, %sftp_args);
当我们调用断开连接方法时,脚本被挂起。
$sftp->disconnect();
我尝试将断开连接处于评估状态,但它仍然没有恢复。
eval {
local $SIG{ALRM} = sub { die "alarm\n" };
alarm 25;
my $retrun = $sftp->disconnect();
alarm 0;
};
my $exception = $@;
msg("Error Dump".Dumper($exception));
}
以下是我在 nohup.out 文件中遇到的错误。
bash: line 1: 27860 Alarm clock sftp_connection.pl
【问题讨论】:
-
你试过
undef $sftp;吗? -
@vkk05 不,我没试过。
标签: perl