Perl Monk, Perl Meditation | |
PerlMonks |
Re^4: Capture::Tiny alternativeby melezhik (Monk) |
on Mar 24, 2017 at 13:47 UTC ( [id://1185780]=note: print w/replies, xml ) | Need Help?? |
Yeah, sure. when I get something to show I will put it here. Meanwhile here is example of how simple script using Perl IPC to read from external program may hangs : $ cat test.pl my $cmd = '/usr/sbin/sshuttle -v -D -r vagrant@127.0.0.1 192.168.0.0/24'; open(OUT, "$cmd 2>&1 |") || die "can't fork: $!"; while (my $l = <OUT>) { print $l; } When I run test.pl it hangs: $ perl test.pl Starting sshuttle proxy. Listening on ('127.0.0.1', 12300). c : connecting to server... vagrant@127.0.0.1's password: c : connected. Connected. ... ^C # I have to enter control C to finish my script When run the same command directly, it does not hang: $ /usr/sbin/sshuttle -v -D -r vagrant@127.0.0.1 192.168.0.0/24 Starting sshuttle proxy. Listening on ('127.0.0.1', 12300). c : connecting to server... vagrant@127.0.0.1's password: c : connected. Connected. $ # finishes without interruption ..
Sshutle information could be found here - https://github.com/apenwarr/sshuttle
And yeah , with Capture::Tiny sshutle does not hang ...
In Section
Seekers of Perl Wisdom
|
|