My perl script needs to ask the user for a password to download some files:
print "Your password please: \n";
ReadMode('noecho');
$password = ReadLine(0);
$password =~ s/\n//;
ReadMode(0);
system("wget --user=user --password=\"$password\" http://some.server/data.xml");
do_something();
If I call the script with $> ./script.pl
everything works fine. But if I want to pipe the output to a file with $> ./script.pl > text.txt
, the password question is piped to the file, too, and the ReadLine does not work any longer.
What is the right way to do this?
Print the prompt to STDERR
:
print STDERR "Your password please: ";