简体   繁体   中英

stty: standard input: Inappropriate ioctl for device

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');
}

I got this error:

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

What is this error? How do I resolve it?

I think the problem is you are reading from a redirected STDIN (because you <file.txt)

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

You should probably pass your file as a parameter to your script.

This message is painful , for users and programmers. It pollutes the STDOUT, sometimes 3 times in a row.

There is no way to suppress it , even with messing with the stty -echo stuff.

The sole solution is to redirect all the errors to /dev/null

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

Annoying, and thus throw away all potential errors, which is not wanted at all .

not wanted at all.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM