RE: [PHP] Catch STDERR



It looks like that will be the situation. Sad that exec() don't have that
feature as an option. Maybe in the future :)

Best regards,
Peter Lauri

www.dwsasia.com - company web site
www.lauri.se - personal web site
www.carbonfree.org.uk - become Carbon Free


-----Original Message-----
From: M.Sokolewicz [mailto:tularis@xxxxxxx]
Sent: Monday, February 19, 2007 11:59 AM
To: Frank Arensmeier
Cc: Peter Lauri; php-general@xxxxxxxxxxxxx
Subject: Re: [PHP] Catch STDERR

you could instead use the proc_* functions to do this. However, seen as
those are pretty complicated and were not available in most php versions
ran by most hosts, a lot of people had to come up with other ways
around it. The most used way is indeed what you described. A simple:
$t = tempnam();
exec('/bin/SomeCommand 2>'.$t);
$stderror = file_get_contents($t);

is what most scripts seem to use currently
- tul

Frank Arensmeier wrote:
Spontaneously, my suggestion would to pipe the STDERR output from your
command to a file. I have to admit that this doesn't feel like the most
efficient solution since you would involve some reading / writing to
your filesystem.

Regards.
//frank

17 feb 2007 kl. 21.49 skrev Peter Lauri:

Hi,

I am executing exec('some cool command', $stdout, $exitcode);

That is fine. I get what I in the beginning wanted. However, now I
need to
catch the STDERR that the command is generating as well. Some of you
might
tell me to redirect STDERR to STDOUT, but that is not possible as I
need to
use the STDOUT as is to automate a process.

I know I can do fwrite(STDERR, 'Output some error\n');

So could I fread(STDERR, SOMESIZE)?

Is there anyone with experience of best way of doing this? Should I maybe
use proc_open or something similar and then write it to a file, and then
read that file? Hrm, doesn't make any sense to do that.

Best regards,
Peter Lauri

www.dwsasia.com - company web site
www.lauri.se - personal web site
www.carbonfree.org.uk - become Carbon Free

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

.



Relevant Pages

  • Re: [PHP] Catch STDERR
    ... However, seen as those are pretty complicated and were not available in most php versions ran by most hosts, a lot of people had to come up with other ways around it. ... I am executing exec('some cool command', $stdout, $exitcode); ... www.dwsasia.com - company web site ...
    (php.general)
  • Re: Change command button colour
    ... > I have seen nowhere how a command button colour is changed. ... > possible through the GUI or programmatically? ... downloads on his web site. ...
    (microsoft.public.access.forms)
  • Catch STDERR
    ... I am executing exec('some cool command', $stdout, $exitcode); ... catch the STDERR that the command is generating as well. ... www.dwsasia.com - company web site ...
    (php.general)
  • Re: How to remove automatically some pages?
    ... Best regards ... Please tell me where is your e-mail address on your web site. ... Word MVP web site http://word.mvps.org ... After the process of MailMerging I delete the "extra" pages using the macro from ...
    (microsoft.public.word.newusers)
  • Re: IE Explorer 6.0 Locking Up On A Web Page Account
    ... Thanks, I will try that running that command again, it didn't work when I ... Connection May No Longer Be Needed was checked, so I uncheck it. ... I should mention that when IE becomes non functional on this web site, ... computer turn OFF this device for Power saving. ...
    (microsoft.public.windowsxp.general)