The problem is, when called through inetd, there is no controlling tty for
the script, so it fails.  I need to figure out how to create a controlling
tty when calling it through inetd.

-jay

> -----Original Message-----
> From: Karl Bongers [mailto:kbongers at mninter.net]
> Sent: Thursday, October 23, 2003 2:31 PM
> To: tclug-list at mn-linux.org
> Subject: Re: [TCLUG] perl, /dev/tty, and pipes
> 
> 
> Hi Jay, You can look to see if you are working on a tty device,
> in c: isatty(fd), with perl I've read "-t /dev/fname" may work,
> or there is a POSIX::isatty().  So I'd suggest:
> if (-t STDIN) {
>   # its a tty device
>   # do funky calls to turn off line buffering and echo.
>   # check out POSIX:Termios as one way to do this.
> }
> 
> &do_your_io;
> 
> if (-t STDIN) {
>   # maybe restore it settings.
> }
> 
> On Thu, Oct 23, 2003 at 02:03:50PM -0500, Austad, Jay wrote:
> > I have this portion of code in a perl script:
> >   #!/usr/bin/perl
> >   #
> >   open(TTY, "+</dev/tty") or die "no tty: $!";
> >   system "stty  -echo cbreak </dev/tty >/dev/tty 2>&1";
> > 
> > When I run it from the command line, it works fine.  
> However, when I pipe
> > data into the script or run it through inetd, I get the 
> following error:
> > 
> > [root at myhost /]# telnet localhost 24
> > Trying 127.0.0.1...
> > Connected to localhost.
> > Escape character is '^]'.
> > no tty: Device not configured at /usr/sbin/spoof.pl line 4.
> > Connection closed by foreign host.
> > [root at myhost /]#
> > 
> > Apparently this is because there is no controlling terminal 
> when I use a
> > pipe or use inetd.  How do I trick it into thinking there 
> is a controlling
> > terminal?  Can I start the perl script through some other 
> trickery, like
> > "bash -i -c /usr/sbin/myscript.pl"? (this didn't work btw)  
> > 
> > The reason I'm using the above, is I need to read input 
> coming in character
> > by character.  Someone mentioned awhile back that screen 
> had some trickery
> > that you could use to get around this.  But I can't find 
> any info.  Any
> > solutions?
> > 
> > -jay
> 
> 
> _______________________________________________
> TCLUG Mailing List - Minneapolis/St. Paul, Minnesota
> http://www.mn-linux.org tclug-list at mn-linux.org
> https://mailman.real-time.com/mailman/listinfo/tclug-list
> 

_______________________________________________
TCLUG Mailing List - Minneapolis/St. Paul, Minnesota
http://www.mn-linux.org tclug-list at mn-linux.org
https://mailman.real-time.com/mailman/listinfo/tclug-list