|
Posted by Toby A Inkster on 07/13/07 12:04
petersprc wrote:
> You can call "stty -echo" to disable echo'ing on the terminal.
Indeed. As an example, the following command ought to prompt for a
password and save it into a file called "foo" without echoing it to the
command line:
stty -echo; echo -n 'Password:'; head -n1 >foo; echo ''
with a bit of imagination, it should be pretty easy to see how you can
work this into a PHP program:
<?php
echo 'Password: ';
$pwd = preg_replace('/\r?\n$/', '', `stty -echo; head -n1`);
echo "\n";
echo "Your password was: {$pwd}.\n";
?>
--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.12-12mdksmp, up 22 days, 15:34.]
demiblog 0.2.0 Released
http://tobyinkster.co.uk/blog/2007/06/28/demiblog-0.2.0/
[Back to original message]
|