May 11, 2009, 7:59 AM
Post #1 of 2
script hangs until a system() call finishes
I have been Perl scripting for a couple of months now. I'm writing a basic script that can read and write variables to and from 2 different computers, using Netcat. My problem, is that when I run my script....it will open the netcat tunnel to the PC in listening mode....dump the 1st thing its supposed to dump...and then hang there (it keeps the netcat connection open, and doesn't die, so the next variable can be written across).
Has anyone else had any issues with this? Any help would be greatly appreciated - here's a snippet of the code to mull over.
my $pid = fork();
while (1 == 1)
if ($pid == 0)
$read = `type netcat.txt`;
if ($read == '')
system('taskkill /F /IM nc.exe');
# print "$read\n";
system('nc 192.168.3.112 1233 > netcat.txt');
ps - I accidentally posted this in the beginner's thread and realized that this probably isn't a beginner's problem...