Php_exec help


trying to use php_exec () to run another php script

shell_exec(“php test.php”);

i get
Status: 404
X-Powered-By: PHP/4.4.2
Content-type: text/html

No input file specified.

but when i run “php test.php” in an ssh session the script runs properly

tried various abolute paths. still no joy. anyone know of a solution?


shell_exec is disabled in Apache for security reasons. I believe that the only way around this is to install your own PHP.



I can use shell_exec for commands like ls and ls -al

some how the argument i.e. the filename is not being passed properly and its getting a file not found error.


I must be remembering from the past when sites were run as the Apache user, and not as yourself.

‘ls’ is fairly harmless, but executing a php script is more of an include.

Here’s a wiki article that describes ways to get around a disabled PHP function:

Again, to gain complete PHP functionality, you’ll need to compile your own PHP.



already though of that. did a “whoami” command and the username came up as myself.

if I do “cat index.php” it works as expected. so the argument is being passed there

but if I do “php test.php” No input file specified.

tried various forms of absolut/relative paths… no joy


Your initial post said that ‘php test.php’ worked as it should. Has something changed?



I have a strong feeling it is nothing more that a path problem. php is a different directory than your php script. Unless you uploaded php to your directory and placed the script in that same directory, which I highly doubt.

My website


I believe silkrooster might be right - its probably a path problem.

In your SSH client, try typing “whereis php” (without the quotes) - that will tell you where PHP is located on the server.

Then in your shell_exec() function, replace php with the full PHP path.

If that doesn’t work - try putting the correct path before test.php - that’s usually /home/DHusername/domain/


“php test.php” works in ssh
not as a shell_exec();

I also made a perl script to execute php test.php
launching from shell, no probs. launching from web. same “no input file.”


whereis php in shell
php: /etc/php /usr/local/bin/php /usr/local/lib/php

whereis php in shell_exec ()
php: /etc/php /usr/local/bin/php /usr/local/lib/php

which php in shell

which php in shell_exec ()

tried shell_exec ("/usr/local/bin/php /home/username/")

still nothing :frowning:


Just for the heck of it try your exec using single quotes instead of double. As there is a period in that string, it may be confusing php.

My website


tried single quotes tried direct back ticks approach…

FYI: this is the code

<?php $foo= shell_exec("php test.php"); echo "
"; ?>

where test.php is - for testing purposes

<?php echo "boo"; ?>


Please test this code:

<?php $foo= shell_exec("/absolute_path/php /absolute_path/test.php"); echo "<pre>$foo</pre>"; ?> :wink: [color=#CC0000]Here[/color] are my Hosting Plan Comparision and $97 off DreamHost Promo Code


nothing :frowning:

can you someone please try on their webspace and tell me if it works.


I tried it using “php absolutepath/test.php” and I got verification that php is indeed working, as it displayed the version of php and some header info multiple times in a row. However the actual text did not display.

My website


do you get this?
Status: 404
X-Powered-By: PHP/4.4.2
Content-type: text/html

No input file specified.


I don’t recall the status , but yes the rest of it is correct.

My website


so you get

“No input file specified.”


No I did not get that.

X-Powered-By: PHP/4.4.2
Content-type: text/html

Over and over.

My website