Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re^6: Capture::Tiny alternative

by Anonymous Monk
on Mar 25, 2017 at 21:21 UTC ( #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?

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2022-01-24 21:10 GMT
Find Nodes?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:

    Results (65 votes). Check out past polls.