CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
script hangs until a system() call finishes

 



b34st1y
Novice

May 11, 2009, 7:59 AM

Post #1 of 2 (553 views)
script hangs until a system() call finishes Can't Post

Hi -

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.


Code
	 

system("cls");
my $pid = fork();


while (1 == 1)
{


if ($pid == 0)
{

$read = `type netcat.txt`;
if ($read == '')
{
system('taskkill /F /IM nc.exe');
print("KILLED");
}
# print "$read\n";
sleep(1);
system('del netcat.txt');
}

else
{
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...


tnaveenkumar
New User

May 11, 2009, 10:41 PM

Post #2 of 2 (539 views)
Re: [b34st1y] script hangs until a system() call finishes [In reply to] Can't Post

i clearly didn't understand the issue, did you mean your script is hung at

system('nc 192.168.3.112 1233 > netcat.txt');

if that is so, and if script is running on windows, you can try following

system('start cmd /c nc 192.168.3.112 1233 ^> netcat.txt');

^ here is escape sequence.

sorry if i havn't understood the proper problem

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives