Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Perl Net::SFTP::外部错误-无法将pty连接为控制终端_Perl_Unix_Sftp_Pty - Fatal编程技术网

Perl Net::SFTP::外部错误-无法将pty连接为控制终端

Perl Net::SFTP::外部错误-无法将pty连接为控制终端,perl,unix,sftp,pty,Perl,Unix,Sftp,Pty,这是基于,但没有完全回答 我正在经历与您相同的行为。我的错误 could not connect pty as controlling terminal! 当我用truss运行脚本时会消失 另外,需要注意的是,当我在服务器上运行脚本时,它工作正常。但是当服务器_B上的另一个脚本调用(通过ssh调用)服务器_A上的脚本时,就会发生错误 我想知道我们是否能够重现这一点和/或是否已经确定了永久解决方案 有关我的环境的一些详细信息: 服务器名称:“SunOS服务器名称5.10通用名称150400-1

这是基于,但没有完全回答

我正在经历与您相同的行为。我的错误

could not connect pty as controlling terminal!
当我用truss运行脚本时会消失

另外,需要注意的是,当我在服务器上运行脚本时,它工作正常。但是当服务器_B上的另一个脚本调用(通过ssh调用)服务器_A上的脚本时,就会发生错误

我想知道我们是否能够重现这一点和/或是否已经确定了永久解决方案

有关我的环境的一些详细信息:

  • 服务器名称:“SunOS服务器名称5.10通用名称150400-11 sun4v sparc sun4v”
  • 服务器的perl版本:v5.18.1
  • Server_B uname:“SunOS Server_B 5.10通用_150400-11 sun4v sparc sun4v”
  • Server_B perl版本:v5.8.7
  • 服务器A:IO::Tty/IO::Pty-版本1.11
  • 服务器A:Net::SFTP::Foreign-版本1.77
下面是我正在使用的代码片段:

#!/usr/local/bin/perl

use Net::SFTP::Foreign;
use IO::Pty;
use POSIX;

## Enable debugging
$Net::SFTP::Foreign::debug = -1;

## Instantiate the variables
my ($action,$host,$user,$pass,$file,$ldir,$rdir) = @ARGV;

## Create the SFTP connection
my $sftp = Net::SFTP::Foreign->new(host     => $host,
                                   user     => $user,
                                   password => $pass);
$sftp->die_on_error("Unable to establish SFTP connection");
以下是调试的输出:

#15593 1400766701.00000 new: This is Net::SFTP::Foreign 1.77
#15593 1400766701.00000 new: Loaded from /export/home/hccprod/lib/Net/SFTP/Foreign.pm
#15593 1400766701.00000 new: Running on Perl v5.18.1 for solaris
#15593 1400766701.00000 new: debug set to -1
#15593 1400766701.00000 new: ~0 is 4294967295
#15593 1400766701.00000 new: Using backend Net::SFTP::Foreign::Backend::Unix 1.76_03
#15593 1400766701.00000 _init_transport: ssh cmd: ssh -o NumberOfPasswordPrompts=1 -o PreferredAuthentications=keyboard-interactive,password -l myusername my.ftp.server -s sftp

Error: could not connect pty as controlling terminal!
#15593 1400766701.00000 _init_transport: starting password authentication
#15593 1400766701.00000 _init_transport: waiting for data from the pty to become available
#15593 1400766702.00000 _init_transport: waiting for data from the pty to become available
#15593 1400766703.00000 _init_transport: waiting for data from the pty to become available
#15593 1400766704.00000 _init_transport: waiting for data from the pty to become available
#15593 1400766705.00000 _init_transport: waiting for data from the pty to become available
#15593 1400766706.00000 _init_transport: waiting for data from the pty to become available
#15593 1400766707.00000 _init_transport: waiting for data from the pty to become available
#15593 1400766708.00000 _init_transport: waiting for data from the pty to become available
#15593 1400766709.00000 _init_transport: waiting for data from the pty to become available
#15593 1400766710.00000 _init_transport: waiting for data from the pty to become available
#15593 1400766711.00000 _init_transport: waiting for data from the pty to become available
#15593 1400766712.00000 _init_transport: waiting for data from the pty to become available
#15593 1400766713.00000 _init_transport: waiting for data from the pty to become available
#15593 1400766714.00000 _init_transport: waiting for data from the pty to become available
#15593 1400766715.00000 _init_transport: waiting for data from the pty to become available
#15593 1400766716.00000 _init_transport: waiting for data from the pty to become available
#15593 1400766717.00000 _init_transport: waiting for data from the pty to become available
Permission denied (publickey,password,keyboard-interactive).
#15593 1400766718.00000 _conn_lost: _conn_lost
#15593 1400766718.00000 _set_status: _set_status code: 6, str: No connection
#15593 1400766718.00000 _set_error: _set_err code: 37, str: SSH slave exited unexpectedly with error code 255
Unable to establish SFTP connection: SSH slave exited unexpectedly with error code 255 at /export/home/username/bin/sftp_service_debug.pl line 31.
#15593 1400766718.00000 DESTROY: Net::SFTP::Foreign=HASH(0x17cc20)->DESTROY called (current pid: 15593, disconnect_by_pid: )
#15593 1400766718.00000 disconnect: Net::SFTP::Foreign=HASH(0x17cc20)->disconnect called (ssh pid: )
#15593 1400766718.00000 _conn_lost: _conn_lost
以下是已打开警告的调试输出:

Unquoted string "vars" may clash with future reserved word at ./test_sftp.pl line 2.
"my" variable $cmd masks earlier declaration in same scope at ./test_sftp.pl line 24.
"my" variable $result masks earlier declaration in same scope at ./test_sftp.pl line 26.
* Calling remote script:
  ssh centralftp "sftp_service_debug.pl 'put' 'host' 'username' 'password' 'file' 'srcdir' 'destdir'"
#7284 1402514985.00000 new: This is Net::SFTP::Foreign 1.77
#7284 1402514985.00000 new: Loaded from /export/home/hccprod/lib/Net/SFTP/Foreign.pm
#7284 1402514985.00000 new: Running on Perl v5.18.1 for solaris
#7284 1402514985.00000 new: debug set to -1
#7284 1402514985.00000 new: ~0 is 4294967295
#7284 1402514985.00000 new: Using backend Net::SFTP::Foreign::Backend::Unix 1.76_03
#7284 1402514985.00000 _init_transport: ssh cmd: ssh -o NumberOfPasswordPrompts=1 -o PreferredAuthentications=keyboard-interactive,password -l onyximport centralftp.pegs.com -s sftp

warning: TIOCSCTTY failed, slave might not be set as controlling terminal: Inappropriate ioctl for device at /export/home/hccprod/lib/IO/Pty.pm line 121.
Error: could not connect pty as controlling terminal!
#7284 1402514985.00000 _init_transport: starting password authentication
#7284 1402514985.00000 _init_transport: waiting for data from the pty to become available
#7284 1402514986.00000 _init_transport: waiting for data from the pty to become available
#7284 1402514987.00000 _init_transport: waiting for data from the pty to become available
#7284 1402514988.00000 _init_transport: waiting for data from the pty to become available
#7284 1402514989.00000 _init_transport: waiting for data from the pty to become available
#7284 1402514990.00000 _init_transport: waiting for data from the pty to become available
#7284 1402514991.00000 _init_transport: waiting for data from the pty to become available
#7284 1402514992.00000 _init_transport: waiting for data from the pty to become available
#7284 1402514993.00000 _init_transport: waiting for data from the pty to become available
#7284 1402514994.00000 _init_transport: waiting for data from the pty to become available
#7284 1402514995.00000 _init_transport: waiting for data from the pty to become available
#7284 1402514996.00000 _init_transport: waiting for data from the pty to become available
#7284 1402514997.00000 _init_transport: waiting for data from the pty to become available
#7284 1402514998.00000 _init_transport: waiting for data from the pty to become available
#7284 1402514999.00000 _init_transport: waiting for data from the pty to become available
#7284 1402515000.00000 _init_transport: waiting for data from the pty to become available
#7284 1402515001.00000 _init_transport: waiting for data from the pty to become available
Permission denied (publickey,password,keyboard-interactive).
#7284 1402515002.00000 _conn_lost: _conn_lost
#7284 1402515002.00000 _set_status: _set_status code: 6, str: No connection
#7284 1402515002.00000 _set_error: _set_err code: 37, str: SSH slave exited unexpectedly with error code 255
Unable to establish SFTP connection: SSH slave exited unexpectedly with error code 255 at /export/home/hccprod/bin/sftp_service_debug.pl line 40.
#7284 1402515002.00000 DESTROY: Net::SFTP::Foreign=HASH(0x17cc20)->DESTROY called (current pid: 7284, disconnect_by_pid: )
#7284 1402515002.00000 disconnect: Net::SFTP::Foreign=HASH(0x17cc20)->disconnect called (ssh pid: )
#7284 1402515002.00000 _conn_lost: _conn_lost

在服务器A上运行脚本,使用一些OS跟踪实用程序作为
truss
,并发布工作和故障(通过服务器B运行)案例的输出

如果你不想公开发布,你可以通过电子邮件将捕获的内容发送给我

作为一种解决方法,您可以尝试从Net::OpenSSH调用Net::SFTP::Foreign,不过您必须安装真正的OpenSSH客户端

my $ssh = Net::OpenSSH->new($host);
my $sftp = $ssh->sftp;

两个模块的密码处理代码相似,但不完全相同。

您好,salva,谢谢回复。问题是,第二种情况只有在没有truss的情况下运行时才会失败。只要我将truss添加到ssh调用中,脚本就会成功(这是目前我的解决方法)。不过,如果您认为这会有所帮助,我将捕获该测试用例的输出并将其发送给您。谢谢。那看起来像某种比赛条件。在模块上启用调试并发布输出:
$Net::SFTP::Foreign::debug=-1
@user3646056:不要对此使用注释。相反,用这些信息更新你的问题。谢谢你的建议。问题已更新。抱歉,直到今天我才注意到您添加-w标志的请求。我重新运行了它,并在上面添加了输出。谢谢。运行向perl传递标志
-w
,这将导致IO::Pty生成更多信息性警告:
/usr/local/bin/perl-w path/to/your/script.pl