【问题标题】:stty: standard input: Inappropriate ioctl for devicestty:标准输入:设备的 ioctl 不合适
【发布时间】:2011-05-01 06:33:57
【问题描述】:
perl script.pl --f1="t1" --f2="t2" --f3="t4" --f4 < /home/joe/a.txt 

脚本.pl

use Getopt::Long;
my ($f1, $f2, $f3, $f4) ;
GetOptions (
            'f1=s' => \$f1,
            'f2=s' => \$f2,
            'f3=s' => \$f3,
            'f4' => \$f4, );
if ($f1) {
    system('stty -echo');
    print "Password:";
    $pwd = <STDIN>;
    system('stty echo');
}

我收到了这个错误:

stty: standard input: Inappropriate ioctl for device
Password:stty: standard input: Inappropriate ioctl for device

这是什么错误?我该如何解决?

【问题讨论】:

  • 第一步是向我们展示脚本正在做什么导致该错误,即:“script.pl”的相关位

标签: linux bash perl


【解决方案1】:

我认为问题在于您正在从重定向的 STDIN 读取(因为您是

$ perl -e 'system("stty -echo");' </tmp/foo
stty: standard input: Inappropriate ioctl for device

您可能应该将文件作为参数传递给脚本。

【讨论】:

    【解决方案2】:

    对于用户和程序员来说,这条消息痛苦。它会污染 STDOUT,有时会连续 3 次。

    没有办法抑制它,即使是搞乱stty -echo 的东西。

    唯一的解决方案是将所有错误重定向到 /dev/null

    ./myscript <<< "some stuffs" 2> /dev/null
    Or similary
    echo "stuffs" | ./myscript 2> /dev/null
    

    烦人,因此丢弃所有潜在的错误,这是根本不需要

    not wanted at all.
    

    【讨论】:

      猜你喜欢
      • 2021-05-11
      • 2018-12-18
      • 2021-12-23
      • 2014-08-28
      • 1970-01-01
      • 2010-12-08
      • 1970-01-01
      • 2014-09-17
      • 2015-02-03
      相关资源
      最近更新 更多