From: Bob Gustafson Date: 2002-05-03T00:44:38+09:00 Subject: Re: How do I use IO.ioctl(arg1, arg2..) Thanks very much for the clue on Termios. I was using Termios on a SerialPort derived device and then printing out everything inside the object. Nothing seemed to be changing and I was still getting the echo. The last line of your echo routine: Termios::setattr($stdin, Termios::TCSANOW, term) seems to be the answer to my problem. Thanks much BobG On Wed, 1 May 2002 23:04:04 -0700, Ian Macdonald wrote: >On Thu 02 May 2002 at 14:39:11 +0900, Bob Gustafson wrote: (Hmm, I wonder how my email date got screwed up..) > >> The pickaxe book is a bit sparse on documentation for using the method >> ioctl for IO class objects. >> >> Is there a guide somewhere? >> >> I want to turn echo on and off on an IO object. >> >> I guess I could use system("stty -F /dev/ttyS1 echo"), if I knew which >> physical device was inside a particular IO object. > >You can also use the termios module for this, although documentation >is rather sparse there, too. > >Here's how you would turn echo on/off for $stdin: > >def echo(on) > term = Termios::getattr($stdin) > if on > term.c_lflag |= Termios::ECHO > else # off > term.c_lflag &= ~Termios::ECHO > end > Termios::setattr($stdin, Termios::TCSANOW, term) >end > >def get_passwd > begin > echo(false) > print "Password: " > $stdin.gets.chomp > ensure > echo(true) > print "\n" > end >end > >Ian >-- >Ian Macdonald | A good plan today is better than a perfect >ian@caliban.org | plan tomorrow. -- Patton > | > | > |