in reply to Re: How do I close a pipe
in thread How do I close a pipe

Thanks BrowserUk

I thought that by closing the handler it will automatically end the child process, but I ended up the other way around, I killed the child process an I don't even need to close the handle, this is how I worked out:

#!/usr/bin/perl $SIG{INT} = \&end; my $kid = open (TELNET, '-|', "telnet 192.168.1.1 6088"); while(<TELNET>) { $arr = <TELNET>; $arr =~ s/[\r\n](.....):(.*)/<p class="$1">$1:$2<\/p>/; print $arr; } end; sub end { kill 9, $kid; ## Or whatever signal is appropriate! print "Session closed!\n" exit; }

But actually I am moving forward now, this version didn't work on Active Perl, I am looking for something that would support as much platforms as I can.

Now instead of use the pipe I use the IO::Socket::INET library with the recv subroutine, but since it is lower level I am having some troubles parsing the lines :P.

Anyways thanks for the help, now this script is helping me a lot for my work.

gmoque