in reply to Re: streaming output to a socket
in thread streaming output to a socket
Here's the same code, reformatted into context:
# Beware of using input from the user in $cmd. my $cmd = 'for f in a b c; do date; sleep 1; done'; while (my $conn = $sock->accept()) { open(PROG, "$cmd|" or die $!; while (<PROG>) { $conn->print($_); } close(PROG); }
If you need to send stuff to $cmd's STDIN, check out the IPC::Open2 and IPC::Open3 modules (included with perl) as an alternative to open ...|.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: streaming output to a socket
by Scarborough (Hermit) on Oct 13, 2004 at 15:44 UTC |