473,763 Members | 6,149 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do I get exec() to display errors?

I would like to display error messages put out by shell commands. For
example the following code gives no output and the array $output has no
values:

<?php
exec( 'lss', $output );
var_dump( $output );
?>

...assuming that I don't have an executable called 'lss' on my computer.

The equivalent on the command line displays the error message:

# php -r 'exec( "lss", $output );'
# sh: lss: command not found

How do I get the exec() command to display errors?

I've tried `exec( 'lss 2/dev/stout', $output );' with no success.

Jul 7 '06 #1
3 14904
Robert S schreef:
I would like to display error messages put out by shell commands. For
example the following code gives no output and the array $output has no
values:

<?php
exec( 'lss', $output );
var_dump( $output );
?>
How about just:
<?php
$strRawOutput = exec( 'lss', $output );
var_dump($strRa wOutput);
?>

This only retrieves the last output line though. If you need more then
you should use passthru() instead of exec().

HTH,
Peter.
--
http://www.phpforums.nl
Jul 8 '06 #2
How about just:
<?php
$strRawOutput = exec( 'lss', $output );
var_dump($strRa wOutput);
?>
This still doesn't print the error message. It only prints whatever is
directed to stdout.

Jul 8 '06 #3
Robert S wrote:
I would like to display error messages put out by shell commands. For
example the following code gives no output and the array $output has no
values:

<?php
exec( 'lss', $output );
var_dump( $output );
?>

..assuming that I don't have an executable called 'lss' on my computer.

The equivalent on the command line displays the error message:

# php -r 'exec( "lss", $output );'
# sh: lss: command not found

How do I get the exec() command to display errors?

I've tried `exec( 'lss 2/dev/stout', $output );' with no success.
2redirection is a shell function, not the OS. You'll need to use
shell_exec() to allow the redirection.

Also, the syntax should be 2>&1. That way if stdout is also redirected
stderr will follow.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Jul 8 '06 #4

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

Similar topics

0
1049
by: Derek | last post by:
I have an ASP.Net application that references multiple projects. If an exception occurs in the startup project I can see what line the error occurs on and the source code, if the error occurs in another project I get the error below. It looks like Visual Studio does not have permission to read the source code, but I gave the local ASPNET user full control to my source code and web application directory. We have another computer with the same...
0
1538
by: Athan | last post by:
I use MS activex treeview control in my asp pages. The problem I have is that some computers display the treeview with no problems while others display the control without the text on the nodes. I checked the IE settings, IE version, comctl32.ocx version,... everything seems to be the same on the machines that do not have the problem and on the machines with the problem... this is a simplified code extract of the treeview control: <object...
2
3478
by: Chuck Anderson | last post by:
I have a public site that creates biorhtym charts using Php. I have put the following in my php.ini file in case of unforeseen errors/warnings: display_errors = Off display_startup_errors = Off log_errors = On error_log = php_error.log Every once in a while I get an entry in my Apache access log file from
4
9048
ak1dnar
by: ak1dnar | last post by:
Hi, I have created a PHP page that write down form data to mySQL table. Before i submit data I want to check the Input field, whether it has filled up or Not. the form should validate from the PHP itself Not from JS or any other client side scripting. when i submit the form by using $PHP_SELF i can trap the errors, but it will delete previously entered values from the page and display empty input boxes. So what i need to do I want...
4
7186
by: Dana Cartwright | last post by:
I have a website in which PHP errors are displayed, despite having them configured to not display. Here is a test file I created to explore this: <?php echo ini_get( 'display_errors' ); phpInfo(); ?>
4
2506
by: Siv Hansen | last post by:
I'm currently working with a server with error reporting level 0, which is good if this was purely a production server. It's not. I have fourty students trying to learn php programming on this server and displaying errors will be a good thing in a learning situation. Is there any way to override the error reporing level set by the server admin? I do not have access to php.ini and server admin will never agree upon changing error...
1
3669
by: nitinpatel1117 | last post by:
I have display errors set to on in my php configuration. i only want to turn of display errors on one particular page/script i have tried to use the set_ini() and error_reporting() functions, but they do not seem to hide the erros ini_set('display_errors', 0); error_reporting(0); none of the above work.
23
9388
by: Maarten | last post by:
Howdy, Recently I switched from a Windows PC to Mac OS-X 10.5 (php v5.2.6) and I have a little problem with one function within my cd-management script. For extracting a bit of info from my cd's I have an executable which I execute with exec(): $discOutput = exec('./discid /dev/rdisk2');
7
2650
by: gregory.lielens | last post by:
Hi, I am using a small python file as an input file (defining constants, parameters, input data, ...) for a python application. The input file is simply read by an exec statement in a specific dictionary, and then the application retrieve all the data it need from the dictionary... Everything is working nicely, but I'd like to have something a little bit more robust regarding input file errors: now any error in the python input script...
0
9563
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9386
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10144
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9937
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9822
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8821
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6642
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3917
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2793
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.