in reply to Re^4: Capture::Tiny alternative
in thread Capture::Tiny alternative

Hello again melezhik ,

Try your command like this:

my $cmd = `/usr/sbin/sshuttle -v -D -r vagrant@127.0.0.1 192.168.0.0/ +24`;

Instead of this:

my $cmd = '/usr/sbin/sshuttle -v -D -r vagrant@127.0.0.1 192.168.0.0/ +24';

Read more about it here (How to run a shell script from a Perl program?).

Seeking for Perl wisdom...on the process of learning...not there...yet!

Replies are listed 'Best First'.
Re^6: Capture::Tiny alternative
by haukex (Archbishop) on Mar 24, 2017 at 15:19 UTC
    my $cmd = `/usr/sbin/sshuttle ...` Instead of this: my $cmd = '/usr/sbin/sshuttle ...'

    I don't think that'll help, as the OP said they want to stream the output of the command, while backticks wait until the external command has completed.

    I suspect there's something going on in the IPC interaction between sshuttle and perl calling it (maybe sshuttle isn't daemonizing properly when called from Perl or something), at the moment I don't know more.

    melezhik: Just a guess, try my $cmd = 'nohup /usr/sbin/sshuttle ...' although that may prevent you from capturing its output, not sure if that's what you want or not. But since you're asking sshuttle to damonize (-D) anyways...

      I don't think that'll help, as the OP said they want to stream the output of the command, while backticks wait until the external command has completed.
      Sure
      Just a guess, try my $cmd = 'nohup /usr/sbin/sshuttle ...' although that may prevent you from capturing its output, not sure if that's what you want or not.
      Unfortunately in real program $cmd comes as users input parameter which I can't alter or modify
      I suspect there's something going on in the IPC interaction between sshuttle and perl calling it
      Yeah, this what I tried to say at the very beginning. There are some rare cases ( rare external commands to interact with ) where Perl/IPC/open ( $cmd |) "hangs" ...
Re^6: Capture::Tiny alternative
by melezhik (Monk) on Mar 24, 2017 at 15:33 UTC
    Anyway, Capture::Tiny::Extended looks like good for me, so I will try ... and let know ...
Re^6: Capture::Tiny alternative
by melezhik (Monk) on Mar 24, 2017 at 15:21 UTC
    yeah, but this way does not work if I want real time STDOUT/STDEER reading ...