?
Solved

PHP exec( ) problems!

Posted on 2003-02-27
7
Medium Priority
?
170 Views
Last Modified: 2006-11-17
Hi all

When I use the exec() call on my Windows 2000 box
in the following form:

exec("command 2>&1",$results);

it works perfectly.  Even if "command" is an incorrect command string $results, as you would expect, will contain the error (ie. Bad command or file name).  But when I use the same structure on Windows 98 only successful "simple" commands work. Nothing is returned at all when there is an error, the $results array is always empty.  This is a problem as I am processing a XML validation using LIBXML and I am interested in finding if there are any errors.    

In the exec call listed above the additional string "2>&1" is supposed to redirect error output to the standard console output.  It doesn't seem that this works in the DOS on 98, is there any way I can return errors to the $results array.

Your help is much appreciated


Kev

0
Comment
Question by:kevadooch
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 15

Expert Comment

by:VGR
ID: 8032750
all I can say is that I avoid it because in the doc it says "exec() may not work on Windows platform"
0
 
LVL 7

Expert Comment

by:Big_Red_Dog
ID: 8033259
The shell processor on W98 is nothing like the one on NT based systems (like WNT, W2000, WXP).  You might ask in the "operating systems" experts area under W98 how to get the errors to go to stdout and then use that in your exec on W98.
0
 

Author Comment

by:kevadooch
ID: 8033338
Unfortunately at this time the only way that one can validate an XML document against a DTD is to use a command line application.  So I'm pretty much reliant on using exec().

A side note is that I have found out that it is pretty much impossible to redirect error output to standard output in Win 98 using the trusty "2>&1" string.  
As the exec() command returns the standard output I'm stumped.  Ahh well, I'll just have to put Windows 2000 or Linux down as a requirement  ...


.. unless anyone knows of a trick of hack to get round this

Cheers

Kev
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 15

Expert Comment

by:VGR
ID: 8033584
have you tried syntax > c:\textfile.txt and reading that file afterwards ?
0
 

Author Comment

by:kevadooch
ID: 8042728
I have been offered a solution by another expert.
You can use a program called "stderr" to merge the
standrad output streams.  This works a treat!!
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 12520267
PAQed with points refunded (50)

Computer101
EE Admin
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question