Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^6: Capture::Tiny alternative

by Anonymous Monk
on Mar 25, 2017 at 21:21 UTC ( [id://1185961]=note: print w/replies, xml ) Need Help??


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

Okay, here's an example of IO::Pty usage. I do not know if there are any modules out there to support such functionality.

sub pty_spawn { my $pty = new IO::Pty; $pty->set_raw(); # stty -opost -echo! my $pid = fork // die; unless ($pid) { $pty->make_slave_controlling_terminal(); # $pty->slave->clone_winsize_from(\*STDIN); close STDIN; close STDOUT; open STDIN, "+>&", $pty->slave; open STDOUT, "+>&", $pty->slave; exit !exec @_; } close $pty->slave; return $pty; }

Calling pty_spawn(@cmd) leaves you with the $pty handle (the master side), that you can read and write. You'll need an event loop if you plan to do both. But if you only read, it should be easy. And you've got the $pid to wait on as usual (for exit status).

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1185961]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2024-04-23 13:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found