Path: utzoo!censor!geac!torsqnt!hybrid!scifi!bywater!uunet!rbj From: rbj@uunet.UU.NET (Root Boy Jim) Newsgroups: comp.lang.perl Subject: CBREAK/RAW Input Message-ID: <118550@uunet.UU.NET> Date: 15 Jan 91 06:32:27 GMT Organization: UUNET Communications Services, Falls Church, VA Lines: 66 HELP! I need to do CBREAK/RAW I/O from a tty. For debugging purposes I and using /dev/tty, which is still open as STD{IN,OUT,ERR}. I am running on SunOS 4.1.1 Perl 3.0@41. I copied the ioctl.pl from a Sequent (4.2 BSD), but it seems to jive with #include . Here's my relevant (probably ugly) code: #! /bin/perl require 'ioctl.pl'; $IN = $0; # any file will do open(IN) || die "can't open $0: $!"; &openNDC || die "can't open NDC $!"; while () { &authorize; } &closeNDC || die "can't close NDC $!"; exit(0); sub openNDC { $sgtty = 'ioekfl'; # place holder open(NDC,'+>/dev/tty') || # for testing die("/dev/tty: $!\n"); ioctl(NDC,$TIOCGETP,$sgtty) || die("TIOCGETP: $!\n"); @sgtty=unpack("ccccs",$sgtty); @sgtty[4] |= $CBREAK; @sgtty[4] &= $ECHO; ioctl(NDC,$TIOCSETP,pack('cccs',@sgtty)) || die("TIOCSETP: $!\n"); # Do I need these? select(NDC); $| = 1; # no buffer select(STDOUT); $| = 1; # no buffer } sub closeNDC { ioctl(NDC,$TIOCGETP,$sgtty) || die("TIOCGETP: $!\n"); close(NDC); } sub authorize { $ans = 'y'; # answer chop; print("authorize $_? "); # ask # Choice of next two methods sysread(NDC,$ans,1); # get answer # $ans = getc(NDC); # get answer print("$ans\r\n"); # echo } -- Root Boy Jim Cottrell Close the gap of the dark year in between