473,404 Members | 2,195 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Command line output bypasses my capture!

I'm trying to capture output from a command line utility (XMLSec), but
only get an empty result. If I call the script from the command line,
I see XMLSec's output, but I can't seem to capture it!

My PHP installation is working correctly and captures other command
line output just fine, XMLSec is the only exception I've found. I've
also tried a couple of other systems to confirm this behavior.

Capture methods I've tried include:

- shell_exec

- exec, with and without output array

- system

- passthru combined with output buffering

- fread-ing from popen('xmlsec1...', 'r')

- proc_open

I get the same result for each of these: an empty string (or array in
the case of exec's $output).

Any idea what's happening here? Any help would be much appreciated.

Aug 20 '07 #1
2 3083
On Mon, 20 Aug 2007 19:33:58 -0000, jdbartlett <co*****@jdbartlett.comwrote:
>I'm trying to capture output from a command line utility (XMLSec), but
only get an empty result. If I call the script from the command line,
I see XMLSec's output, but I can't seem to capture it!

My PHP installation is working correctly and captures other command
line output just fine, XMLSec is the only exception I've found. I've
also tried a couple of other systems to confirm this behavior.

Capture methods I've tried include:

- shell_exec

- exec, with and without output array

- system

- passthru combined with output buffering

- fread-ing from popen('xmlsec1...', 'r')

- proc_open

I get the same result for each of these: an empty string (or array in
the case of exec's $output).

Any idea what's happening here? Any help would be much appreciated.
Is it writing to stderr (standard error) instead of stdout (standard output)?
--
Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Aug 20 '07 #2
On Aug 20, 3:39 pm, Andy Hassall <a...@andyh.co.ukwrote:
On Mon, 20 Aug 2007 19:33:58 -0000, jdbartlett <cont...@jdbartlett.comwrote:
I'm trying to capture output from a command line utility (XMLSec), but
only get an empty result. If I call the script from the command line,
I see XMLSec's output, but I can't seem to capture it!
My PHP installation is working correctly and captures other command
line output just fine, XMLSec is the only exception I've found. I've
also tried a couple of other systems to confirm this behavior.
Capture methods I've tried include:
- shell_exec
- exec, with and without output array
- system
- passthru combined with output buffering
- fread-ing from popen('xmlsec1...', 'r')
- proc_open
I get the same result for each of these: an empty string (or array in
the case of exec's $output).
Any idea what's happening here? Any help would be much appreciated.

Is it writing to stderr (standard error) instead of stdout (standard output)?
--
Andy Hassall :: a...@andyh.co.uk ::http://www.andyh.co.ukhttp://www.and....co.uk/space:: disk and FTP usage analysis tool
One of those slap-forehead-with-palm "D'oh! I'm an idiot!" moments.

Thank you! Yes, of course, that's exactly what's happening.

IMO, that's a very odd way for a utility to act, but that doesn't make
me feel any less an idiot!

For anyone stumbling into this thread with a similar problem, you need
to reroute stderr to stdout (and stdout to /dev/null if you want
errors only), like so:

var_dump(shell_exec('xmlsec1 verify --id-attr:id Body --trusted-pem
my_public.crt my_signed.xml * 2>&1 1>/dev/null'));

Thanks again!

Aug 20 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Peter A. Schott | last post by:
Per subject - I realize I can copy/paste a line at a time into an interactive session when I'm trying to debug, but was wondering if there is any tool out there that allows me to copy sections of...
9
by: Tommy Lu | last post by:
Hi, wondering if there is a way to interact the shell command with the C# program? For example, if I type c:\>ver it then suppose to return the version of the OS I am currently using... or ...
1
by: Ernesto | last post by:
I'm looking for a way to capture command line output from a cmd session. Is there a way to use python to launch the application from the beggining.... then stream all of the output to a text...
4
by: Peter A. Schott | last post by:
Not sure what I should do here. I know that DOS/CMD can capture the output of EXE files in Win32. I know that os.popen() has been recommended for this, but the couple of times I've tried, it...
5
by: nic | last post by:
On my system (WinXP) typing the following line into command prompt(cmd.exe) successfully scans the file test1.txt: "c:\Program Files\Grisoft\AVG Free\avgscan.exe" "c:\program...
10
by: lalnamar | last post by:
I want to execute a unix time command using perl, and capture the output (specifically, the time it takes the command to execute). i tried using the system command: system("time command ");...
6
by: Goran07 | last post by:
Hello, all, I see there are some true experts here on the forum, so maybe someone can help me. I need to get output from DOS application that does some calculations based on the choices that user...
4
by: amjadcsu | last post by:
Hi I am trying to execute a command using os.system. this command lists the number of nodes alive in a cluster. I would like to capture the output in list/array in python. IS it possible.?/ ...
2
by: megatrious | last post by:
I have a windows command line tool that accepts certain input parameters and runs a process and displays a report. I want to develop a Java GUI for that tool. Input parameters need to be given in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.