Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4252418
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T04:47:33+00:00 2026-05-21T04:47:33+00:00

For common commands like ‘ls’, exec() works fine, eg: exec(‘ls’,$output,$retval); var_dump($output,$retval); // $output contains

  • 0

For common commands like ‘ls’, exec() works fine, eg:

exec('ls',$output,$retval);
var_dump($output,$retval);
// $output contains an array of filenames, and retval === 0

But when trying to execute another program, I can’t get the output:

exec('some_command --a_parameter',$output,$retval);
var_dump($output,$retval);
// $output contains an empty array, end $retval === 0

This command prints some lines when executing it directly from the command-line though.
I know the command has been successful because of the results (some files updated, data added, etc), and yet I can’t see the output.

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T04:47:34+00:00Added an answer on May 21, 2026 at 4:47 am

    It sounds like the program is outputting its warnings to standard error rather than standard output. exec will only catch standard output. I don’t know for certain that standard error is always sent to the apache error log, but it seems likely.

    If you don’t need compatibility with non-*nix systems, you can redirect standard error to standard output by appending 2>&1 to the command:

    exec('some_command --option 2>&1', $output, $ret);
    

    This should both make the warnings available to your php program and prevent unnecessary logging.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This seems like it would be a common problem, but I just can't seem
I'd like to re-map my EMACS to put the most common commands on the
Common problem I'm sure, but I can't figure it out. In my AndroidManifest.xml and
Is there a common library which helps to implement commands entered on a Java
I know it is common to use catch when executing commands that may return
This problem is so simple and common but I still haven't been able to
I need to setup different commands for ViewModels like Close, Edit, Cancel, ShowPic, ShowVideo.
I'd like to disable PowerShell's common parameters for one of my functions. I've been
I have a django app with two management commands, which both call a common
Sorry I know similar question have been asked many times before but like most

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.