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 6706023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:28:17+00:00 2026-05-26T07:28:17+00:00

I have three php scripts. One, I start with init script. The second is

  • 0

I have three php scripts. One, I start with init script. The second is started by the first one itself and the second then uses shell_exec to get output from the third script by passing various params to it periodically.

But it’s not happening. When I var_dump the output of shell_exec, in the second script, I get NULL. But when I print the actual command which is used in shell_exec in the second script and try entering it into console, it works very well!

I tried the command from console of same user with which I start the init script.

This might be a permission issue. But I have the proper permissions setup i.e.

  1. +x for the third script
  2. the third script (actually all the three are) is owned by the same user and group I use the console with

Note – I tried starting the third script with shebang as well as by removing the shebang and adding php before the script path. With root everything runs fine.

Also, just another note, the first script redirects output of the second script to a log file (this is where I found the third script returning NULL on shell_exec)

UPDATE: The code from second script which uses shell_exec

$command = "/var/data/user-data.php '{$user}' '{$request['token']}' '{$request['secret']}'";
$data = json_decode( shell_exec( $command ), true );   

I tried printing $command and also var_dump( shell_exec( $command ) ). The former one returns what is expected (the params) and the latter returns NULL

  • 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-26T07:28:18+00:00Added an answer on May 26, 2026 at 7:28 am

    Without directly commenting on what the problem is –

    Stop. Don’t shell out. This is a security minefield.

    $command = "/var/data/user-data.php '{$user}' '{$request['token']}' '{$request['secret']}'";
    

    What happens if the user passes, say:

    http://yoursite.com/index.php?token=';rm -rf / #
    

    Answer: Your entire server is erased (or at least anything the PHP script user can touch). Naturally there are other, more insidious things people can do. And this sort of vulnerability can and will be found by automated scanners, which will in turn automatically root your server.

    So don’t shell out, particularly when you’re just calling another PHP script. Put your code into a function, include the php file containing it, and call the function when you need the data.

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

Sidebar

Related Questions

I have one PHP script that has to start a second script in the
I have three files: one called sql.php witch has a class db that I
I have three files in a folder 'test' one.php two.php print.html And i have
I have a PHP script that builds a binary search tree over a rather
Is there any way to have PHP automatically call a function, before a script
I have three update statements to be executed in PHP, i am getting the
First of all, I just started PHP. I know my methods might not be
I need to send newsletters. I have already a PHP script that sends mass
I have php scripts that I have to run on linux as well as
I have read many php tutorials for logout scripts, i am wondering what could

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.