perl script.pl --f1="t1" --f2="t2" --f3="t4" --f4 < /home/joe/a.txt
script.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
这个错误是什么? 我该如何解决?
我认为问题在于你正在从重定向的STDIN中读取(因为你<file.txt)
$ perl -e 'system("stty -echo");' </tmp/foo stty: standard input: Inappropriate ioctl for device
你应该把你的文件作为参数传递给你的脚本。