[ale] OT Perl Question

Christopher Fowler cfowler at outpostsentinel.com
Wed May 14 20:29:08 EDT 2003


Posix::Termios

Only work on Posix system though

Below is an example of cfmakeraw() for perl.  It is not
a POSIX standard so it was not ported to perl.  I recreated
it based on the termios man page.  If you use it to read,
you'll need to use sysread to read STDIN  But,
All you are concerned with is ECHO.



sub cfmakeraw {
        my $tty = $_[0];
        $tty->getattr();
        my $c_iflag = $tty->getiflag();
        my $c_oflag = $tty->getoflag();
        my $c_lflag = $tty->getlflag();
        my $c_cflag = $tty->getcflag();
        $tty->setiflag($c_iflag &= ~&POSIX::IGNBRK);
        $tty->setiflag($c_iflag &= ~&POSIX::BRKINT);
        $tty->setiflag($c_iflag &= ~&POSIX::PARMRK);
        $tty->setiflag($c_iflag &= ~&POSIX::ISTRIP);
        $tty->setiflag($c_iflag &= ~&POSIX::INLCR);
        $tty->setiflag($c_iflag &= ~&POSIX::IGNCR);
        $tty->setiflag($c_iflag &= ~&POSIX::ICRNL);
        $tty->setiflag($c_iflag &= ~&POSIX::IXON);
        $tty->setoflag($c_oflag &= ~&POSIX::OPOST);
        $tty->setlflag($c_lflag &= ~&POSIX::ECHO);
        $tty->setlflag($c_lflag &= ~&POSIX::ECHONL);
        $tty->setlflag($c_lflag &= ~&POSIX::ICANON);
        $tty->setlflag($c_lflag &= ~&POSIX::ISIG);
        $tty->setlflag($c_lflag &= ~&POSIX::IEXTEN);
        $tty->setcflag($c_cflag &= ~&POSIX::CSIZE);
        $tty->setcflag($c_cflag &= ~&POSIX::PARENB);
        $tty->setcflag($c_cflag | &POSIX::CS8);
}

my $termios = POSIX::Termios->new;
my $old = POSIX::Termios->new;
$termios->getattr();
$old->getattr();
cfmakeraw($termios);
$termios->setattr( 0, &POSIX::TCSANOW );

On Wed, May 14, 2003 at 08:13:46PM -0400, Robert Heaven wrote:
> I need to write a short perl script that will prompt me for a password
> without echoing what I type. Any ideas?
_______________________________________________
Ale mailing list
Ale at ale.org
http://www.ale.org/mailman/listinfo/ale





More information about the Ale mailing list