[英]How to supress the “stty: 'standard input': Inappropriate ioctl for device” error
[英]stty: standard input: Inappropriate ioctl for device
perl script.pl --f1="t1" --f2="t2" --f3="t4" --f4 < /home/joe/a.txt
脚本文件
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
这是什么错误? 我该如何解决?
我认为问题在于您正在从重定向的 STDIN 中读取数据(因为您是 <file.txt)
$ perl -e 'system("stty -echo");' </tmp/foo
stty: standard input: Inappropriate ioctl for device
您可能应该将您的文件作为参数传递给您的脚本。
这个消息对于用户和程序员来说是痛苦的。 它会污染 STDOUT,有时会连续 3 次。
没有办法抑制它,即使弄乱了stty -echo
东西。
唯一的解决方案是将所有错误重定向到/dev/null
./myscript <<< "some stuffs" 2> /dev/null
Or similary
echo "stuffs" | ./myscript 2> /dev/null
烦人,因此扔掉所有潜在的错误,这是根本不想要的。
not wanted at all.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.