![](/img/trans.png)
[英]how to ask for username and password with a shell script on linux and windows
[英]How to ask for password on the Windows console in a Perl script?
我嘗試了以下代碼
use strict;
use warnings;
use Term::ReadPassword::Win32 qw(read_password);
my $pw = read_password('pw: ');
print "pw $pw\n";
my $x = <STDIN>;
print "x: $x\n";
它確實要求輸入密碼並且不回應答案,但它會跳過它后面的<STDIN>。 我想這是Term :: ReadPassword :: Win32中的一個錯誤,所以我想知道是否有另一個模塊在Windows上運行良好?
http://www.perlmonks.org/?node_id=886306報告相同的問題,並使用Term :: ReadKey提供備用的讀取密碼實現。 底層問題是Win32 :: Console中的這個錯誤 ,可以通過重新打開STDIN和/或STDOUT來解決。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.