-
ThirtySecondNoob
-
RE: Using Shell code in Perl - `Backticks`
-
Hi gomer,
I have the simplest code I could wish for in this reply here. I am thinking that this is the code I want, for with I had used "netcat localhost 12345". The recieve (recv SOCKET,SCALAR,LENGTH,FLAGS) function I am thinking is the one I want, although the description for its FLAGS is too vague - "Takes the same flags as the system call of the same name. "
My -f is just a guess for a proper flag, but i cannot disclude any flags for they are a mandatory parameter.
I have included my code's test case below. When I ran this program, I expected when a line went through the data feed, it would be printed on the screen. I tested this with a separate shell and it was not the case. Do you have any ideas on what I might be doing wrong?
###
use IO::Socket::INET;
$sock = IO::Socket::INET->new(Listen => 1, #queue size for listen
LocalAddr => 'localhost',
LocalPort => 12345,
Proto => 'tcp');
while(1)
{
my $new_line;
recv($sock, $new_line, 200, -f);
if (!$new_line) {next;}
print $new_line."\n";
}
###
-
01 Oct 10
Hi gomer,
I have the simplest code I could wish for in this reply here. I am thinking that this is the code I want, for with I had used "netcat localhost 12345". The recieve (recv SOCKET,SCALAR,LENGTH,FLAGS) function I am thinking is the one I want, although the description for its FLAGS is too vague - "Takes the same flags as the system call of the same name. "
My -f is just a guess for a proper flag, but i cannot disclude any flags for they are a mandatory parameter.
I have included my code's test case below. When I ran this program, I expected when a line went through the data feed, it would be printed on the screen. I tested this with a separate shell and it was not the case. Do you have any ideas on what I might be doing wrong?
###
use IO::Socket::INET;
$sock = IO::Socket::INET->new(Listen => 1, #queue size for listen
LocalAddr => 'localhost',
LocalPort => 12345,
Proto => 'tcp');
while(1)
{
my $new_line;
recv($sock, $new_line, 200, -f);
if (!$new_line) {next;}
print $new_line."\n";
}
###