G
Glodalec
Hi !
My B program is a simple script, which reads a string from STDIN,
converts it to uppercase and prints it to STDOUT.
B.pl
#!/bin/perl
use strict ;
my $string=<STDIN>;
print STDOUT uc $string,"\n" ;
Now, I have A program, which listens on a TCP socket. Whenever string
come over socket, it should be put on STDIN buffer (yes, STDIN), forking
a new child, redirecting the parent SOCKET to child's STDOUT and exec
B.pl. (The same way Apache & CGI modules work). I was trying to use
select() but no luck.
A.pl
#!/bin/perl
use strict ;
....
SOCKET CREATION, LISTENING, GETTING LINE FROM A SOCKET INTO $LINE
....
TCP settings....
.......
if (my $pid=fork)
{
waitpid($pid,0); # Ok, here is parent
} else
{
my $string="This must be put in STDIN buffer" ; << Don't know how
my $old=select(SOCKET) ; << This is not working
exec("A.pl"); # and child
select $oldstdout ;
}
Any help would be appreciated
My B program is a simple script, which reads a string from STDIN,
converts it to uppercase and prints it to STDOUT.
B.pl
#!/bin/perl
use strict ;
my $string=<STDIN>;
print STDOUT uc $string,"\n" ;
Now, I have A program, which listens on a TCP socket. Whenever string
come over socket, it should be put on STDIN buffer (yes, STDIN), forking
a new child, redirecting the parent SOCKET to child's STDOUT and exec
B.pl. (The same way Apache & CGI modules work). I was trying to use
select() but no luck.
A.pl
#!/bin/perl
use strict ;
....
SOCKET CREATION, LISTENING, GETTING LINE FROM A SOCKET INTO $LINE
....
TCP settings....
.......
if (my $pid=fork)
{
waitpid($pid,0); # Ok, here is parent
} else
{
my $string="This must be put in STDIN buffer" ; << Don't know how
my $old=select(SOCKET) ; << This is not working
exec("A.pl"); # and child
select $oldstdout ;
}
Any help would be appreciated