stty:标准输入:设备不适当的ioctl

时间:2010-10-27 11:39:17

标签: linux bash perl

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

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

2 个答案:

答案 0 :(得分:3)

我认为问题是你是从重定向的STDIN读取的(因为你&lt; file.txt)

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

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

答案 1 :(得分:0)

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

即使弄乱index(i) argument in higher order function filter东西,也没有没有办法抑制它

唯一的解决方案是将所有错误重定向到 from pyspark.sql import functions as F from pyspark.sql.window import Window w=Window().orderBy("time") df.withColumn("lag1", F.lag("time").over(w)).withColumn("lag2", F.lag("data").over(w))\ .withColumn("collect", F.sort_array(F.collect_list(F.array("lag1","lag2")).over(w),False)).drop("lag1","lag2")\ .withColumn("collect", F.when(F.size("collect")>1,F.array(F.element_at("collect",1),F.element_at("collect",2)))\ .otherwise(F.col("collect")))\ .withColumn("collect", F.when(F.size("collect")<2, F.flatten(F.array_repeat("collect",2)))\ .otherwise(F.col("collect")))\ .select("time","data",*[(F.col("collect")[x][y]).alias("{}".format(z))\ for x,y,z in zip([0,0,1,1],[0,1,0,1],['time1','data1','time2','data2'])])\ .show(truncate=False)

stty -echo

烦人,从而消除了所有可能的错误,这是根本不需要的

/dev/null
相关问题