Re: CLI script & exec() - how to control what gets dumped on the screen.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Myron Turner wrote:
> exec() doesn't output anything.  It fills the array with the result

'the result' is a bit of a nebulous concept - exec() fills the output array
with whatever the called script/program *spat out on stdout*.

my fault was indeed thinking along such 'the result' lines - I did
not consider that stderr was not part of 'the result' and that most
programs seem to happily spit out their output to stderr (e.g. apache2ctl,
cvs, mysql to name a few that I was calling in the problem script) and yes
I'm still rather baffled as to why something like apache2ctl would
dump the string 'Syntax OK' to stderr - if ever there was some user feedback
that *didn't* represent an error it would be 'Syntax OK'.

idiosyntastic (yes I know that not a word)

> (your $output) and then you have to loop through the array and print it
> to the screen, appending your own line-feeds.

ah so you got the the photo of me with "total f'ing noob"
tattooed on my forehead then?

obviously the photo is not of very good quality because the tattoo actually
says:

	"this idiot is liable to write WITH when he means WITHOUT"

2 other people did successfully manage to translate the WITH to WITHOUT
based on the rest of what I wrote - thankfully :-)

> 
> See the PHP manual page.

wassat?

> 
> 
> Myron
> 
> Jochem Maas wrote:
>> I have been trying to figure out how to use exec to run some commandline
>> scripts (some perl scripts & mysql in this case) WITH the output of
>> the commands
>> run via exec being shown on the screen.
>>
>> neither of these examples have the desired effect:
>>
>>     $output = array(); $exit = 0;
>>     exec('apache2ctl graceful', $output, $exit);
>>
>>
>>     $output = array(); $exit = 0;
>>     @exec('apache2ctl graceful', $output, $exit);
>>
>> please someone tell me there is a decent way to do this (something
>> to do with STD input/output redirection or something?) and that I'm
>> not left
>> with trying something like:
>>
>>     ob_start();
>>     $output = array(); $exit1 = $exit2 = 0;
>>     @exec('apache2ctl graceful', $output, $exit1);
>>     ob_end_clean();
>>
>> ... of which I don't even know if it would work.
>>
>> anyone care to share their clue?
> 
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux