Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Mac OS X > Redirecting Output (PHP Involved)

Redirecting Output (PHP Involved)
Thread Tools
Grizzled Veteran
Join Date: Jun 2001
Status: Offline
Reply With Quote
Aug 21, 2004, 09:14 PM
 
I've got a command-line app that continuously prints to the screen, and I'd like to be able to either dump that data to a file or (preferable) grab the last n lines with PHP, as it will be started from a PHP script. Is there a way to do either of those?

They mention on the PHP.net exec() function list that if you want to do just that, then you should redirect the output to a file. I tried using > to redirect it, but it hangs there waiting for the app to finish (regardless of whether I call it from PHP or right from a terminal). What other methods are there of redirecting output?
     
Mac Elite
Join Date: Oct 2000
Location: Seattle
Status: Offline
Reply With Quote
Aug 22, 2004, 02:35 AM
 
You're looking at communicating with a process while it's running. You may have to do some of the fancier PHP pipes stuff like popen() or proc_open()


Something like exec('/bin/my_script > file.txt') should set the script in motion and not hang around for the result. Maybe you don't have the correct file permissions or something.

I'd set error_reporting(E_ALL); before the exec line and see if you get more info.

Try piping the script to a file in the terminal and see what happens; test it with php out of the loop, could be something odd with the script.


http://www.php.net/manual/en/function.popen.php

http://www.php.net/manual/en/function.proc-open.php
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 06:39 AM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2