【问题标题】:Running perl script with Net::SSH::Expect package in cygwin environment from DOS CMD在 DOS CMD 的 cygwin 环境中使用 Net::SSH::Expect 包运行 perl 脚本
【发布时间】:2011-08-24 14:30:46
【问题描述】:

我成功地从 cygwin 命令提示符运行了使用 Net::SSH::Expect 包的 Perl 脚本。但我想通过 windows 2003 的任务计划或通过 cygwin 的 crontab 或从 DOS 命令提示符运行脚本在中间失败并出现以下错误。

错误:

SSHAuthenticationError Login timed out. The input stream currently has the conte
nts bellow: Pseudo-terminal will not be allocated because stdin is not a termina
l.
at /usr/lib/perl5/site_perl/5.10/Expect.pm line 828

密码:

任何人都可以帮助我解决这个问题.. 提前致谢。 基肖尔。

【问题讨论】:

    标签: perl cygwin perl-module


    【解决方案1】:

    您需要在启动 SSH 的命令行中强制或禁用伪 TTY 的分配,方法是将 -T 或 -t 选项传递给 SSH。 From the SSH man page:

     -T      Disable pseudo-tty allocation.
    
     -t      Force pseudo-tty allocation.  This can be used to execute arbi-
             trary screen-based programs on a remote machine, which can be
             very useful, e.g. when implementing menu services.  Multiple -t
             options force tty allocation, even if ssh has no local tty.
    

    【讨论】:

    • 非常感谢您的回复,我尝试了SSH的-t和-T选项,但问题仍然存在。
    • @user398026:你不应该同时使用这两个。
    • 您能提供您的代码吗?我希望您可能有多个 ssh 调用。
    • 这里是代码:退出 SSH::Expect 构造函数。使用 Net::SSH::Expect; open(INPUT,">/all_output") 或 die "无法打开\n\n";打印输入“你好世界”; print INPUT "这是基肖尔。\n";打印“你好世界\n”; print "这是基肖尔。\n";我的 $ssh = Net::SSH::Expect->new ( host => '16.138.181.29',password=>'hpsa*help',user =>'root', timeout =>10, ssh_option=>'- t'); print INPUT "连接后\n\n"; print "连接后\n";我的 $login_output = $ssh->login(); print INPUT "login_output is $login_output \n";
    猜你喜欢
    • 2020-01-06
    • 1970-01-01
    • 2016-12-06
    • 2020-07-04
    • 2020-11-09
    • 2016-08-16
    • 2017-05-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多