user443346
user443346

Reputation:

shell_exec phpfile

I currently use this code:

if(isset($_POST['url']) && isset($_POST['trefwoorden']) )
{
  mysql_connect('localhost', 'crawler', 'whathasbeenseencannotbeunseen');
  mysql_select_db("crawler");
  mysql_query("INSERT INTO jobs (jobID, url, trefwoorden) VALUES ('', '".$_POST['url']."', '".$_POST['trefwoorden']."')");
  $output = shell_exec("./content.php " .mysql_insert_id());
  echo $output;

}

In my content.php I have the following code:

#!/usr/bin/php
<?php
echo 'HET WERKT';
?>

Now I want to see if my shell_exec actually works by filling in the form and submitting it: but it doesn't echo anything at all.

Did I write wrong code?

Upvotes: 0

Views: 899

Answers (3)

ITroubs
ITroubs

Reputation: 11215

Why do you invoke a PHP file and not including it?

Besides, I agree with Chouchenos because this line of code:

shell_exec('php -l content.php'. mysql_insert_id())

will execute like this "php -l content.php132" if mysql_insert_id() returns the id 132.

This might be a problem because content.php132 might not be existant.

Upvotes: 0

user455982
user455982

Reputation:

Try this. This may help you.

shell_exec('usr/local/bin/php -l content.php'. mysql_insert_id())

or

shell_exec('usr/local/bin/php -content.php'. mysql_insert_id())

All the best.

Thanks,

Kanji

Upvotes: 1

Bas van Dorst
Bas van Dorst

Reputation: 6630

.. Maybe this will work for you:

shell_exec('php -l content.php'. mysql_insert_id())

Or;

  1. PHP is running in safe_mode
  2. Apache does not have the permissions to execute the script

Upvotes: 0

Related Questions