Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: Wrap around an interactive python script

by ahmad (Hermit)
on Jul 21, 2010 at 02:17 UTC ( #850542=note: print w/replies, xml ) Need Help??

in reply to Wrap around an interactive python script

You can do this through open pipe, but you might run into some buffering problems.

open(LOG,">>/path/to/log"); open(SYS,"/path/to/python/ |"); while (<SYS>) { print $_; print LOG $_; } close(SYS); close(LOG);

This way you can print to screen and to your log file

Replies are listed 'Best First'.
Re^2: Wrap around an interactive python script
by rastoboy (Monk) on Jul 21, 2010 at 04:08 UTC
    I've recently started using IPC::Open3::open3 for InterProcess Communication type purposes and haven't looked back. Makes it easy to interact with another application by just reading and writing to filehandles, very slick and more intuitive (at least for me, anyway).

    But I'm still quite the amateur and may be missing some subtleties (or outright facts).

      While open3 does a lot (incl propagating exec errors to the parent), it's still a low level module. It's doesn't help you read from the child's STDOUT and its STDERR without combining them, a situation prone to deadlocks. IPC::Run3 and IPC::Run are higher-level solutions.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2021-10-26 13:52 GMT
Find Nodes?
    Voting Booth?
    My first memorable Perl project was:

    Results (90 votes). Check out past polls.