php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #13512 The backtick operator only returns stdout, not stderr
Submitted: 2001-10-02 10:27 UTC Modified: 2007-07-24 15:40 UTC
From: strecket at hotmail dot com Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 4.0.5 OS: FreeBSD
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: strecket at hotmail dot com
New email:
PHP Version: OS:

 

 [2001-10-02 10:27 UTC] strecket at hotmail dot com
If I use the backtick operator, like:

 $output = `command goes here`;

and if the program 'command' returns its output to stderr and not stdout, then it's not easy to get the output.

Right now, it can be solved by adding:

 2> /tmp/file/here

and then reading the file in the script, but that's not a good solution.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-10-05 03:20 UTC] edink@php.net
What you want can be probably be achieved with:

$output = `command 2>&1`;

 [2001-10-05 05:02 UTC] strecket at hotmail dot com
RE: edink@php.net

Yes, but that's platform specific solution, so I think it would be better to make PHP return the output to stderr too.

For example, that doesn't work on Win9x.
 [2007-07-24 15:40 UTC] jani@php.net
It works fine in the windows versions I've tried it on. And current PHP versions don't work with Win9x anyway -> bogus.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jan 15 15:01:31 2025 UTC