redirecting stderr and stdout 
Author Message
 redirecting stderr and stdout

I'm writing a client-server application in Perl, but have run into a
problem and am hoping that someone can assist me.  

I have a client program, client.pl, which is a perl script that sends
its command line arguments to a server (after massaging them a bit),
and prints responses to stdout and stderr.  This works great.

To support sites that cannot run client.pl, I will provide a port on
my system for remote sites to telnet into.  Each line of input from
that port will be run through client.pl on my system and the resulting
stdout and stderr sent back to the remote user through the socket.  My
plan for this is to write another shell script, telnet.pl, which is
a wrapper around client.pl.  

I'm having trouble writing telnet.pl, specifically with redirecting
i/o.  I have tried using

        ## lots of setup omitted here.  NET is the network stream.

        $result = eval `cat client.pl`;

        print NSTR "\n";

But this gives only long output line, instead of many strings, which
is bad when telnetting from a VMS system.  (the lines are separated by
LF with no CR.)

Another attempt was

        $result = &client_command(NET,NET,&shellwords);

where client_command is the only significant line in client.pl.  The
first two arguments are the streams for STDOUT and STDERR, and the
output commands in client_command use the streams passed as those
args.  But this doesn't work well, because client_command runs "die"
frequently, and that writes its output to STDERR, not NET, and there
doesn't seem to be a way to change that.

Does anyone have any suggestions on how to go about writing this
telnet handler?  

Thanks,

Mike Rose
--



Sun, 08 Oct 1995 22:53:13 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. redirect STDERR to STDOUT ?????

2. Redirect stderr to stdout w/ Perl under Unix?

3. Redirecting STDERR to STDOUT (on NT)

4. Redirecting STDERR to STDOUT?

5. redirecting stderr to stdout

6. redirect stderr and stdout to same file

7. redirect stderr and stdout to the same file

8. Redirect stderr to stdout inside perl script

9. Redirecting stderr to stdout

10. how to redirect stderr and stdout to same file

11. How do I redirect STDERR and STDOUT?

12. Redirecting STDERR to STDOUT

 

 
Powered by phpBB® Forum Software