Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: capture STDOUT when some jerk opened STDOUT to /dev/tty

by Corion (Pope)
on Jan 07, 2013 at 18:04 UTC ( #1012077=note: print w/replies, xml ) Need Help??


in reply to capture STDOUT when some jerk opened STDOUT to /dev/tty

Why not fake modifying the script by using do?

select MYSTDOUT; # use *MYSTDOUT instead of STDOUT for output # so all his reopening manipulates the wrong filehandle # Run the original script in our interpreter do 'original_script.pl' or die;

Update: Also, you should be able to combine this with davido's recommendation of Capture::Tiny to do the (re)capturing before the main script starts.

Update 2: No, it's unlikely. The Capture::Tiny documentation says:

Attempting to modify STDIN, STDOUT or STDERR during capture or tee is almost certainly going to cause problems. Don't do that.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1012077]
help
Chatterbox?
[LanX]: davies: same problem
[Corion]: It had been approved as a Perl Monks Discussion. It should now be approvable into SoPW
[choroba]: Approved
[LanX]: hmm aproval doesn't stick after move? Or was it a race condition
[Corion]: I think you need at least one reload after moving before you can approve in the correct section
[GotToBTru]: it was approved . but isnt now
[GotToBTru]: ah nevermind .. i was looking at one of 2

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (11)
As of 2017-01-16 15:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you watch meteor showers?




    Results (151 votes). Check out past polls.