0

This is my php script

<HTML>
<head>
    <h1>Hello</h1>
</head>
  <body>
    <?php
 $command=escapeshellcmd('~/PycharmProjects/Test_1/wiki_update.py 2 2>&1');
 $output=shell_exec($command);
 echo $output;
 ?>
</body>   
 </HTML>

I get no output when I run it through the browser.

When I change the $command=escapeshellcmd('whoami');

it outputs as NOBODY,

I granted permission to nobody for that python script still no output.

I am using xampp for linux and php script in htdocs/xampp.

2
  • Try dumping $command as a string and running it manually using your shell. Commented Mar 31, 2014 at 21:04
  • it works through shell .. php trial.php runs perfectly but not through browser which is what I want. Commented Mar 31, 2014 at 21:07

1 Answer 1

1

Are you sure you don't need to change your command to run python?

 $command=escapeshellcmd('python ~/PycharmProjects/Test_1/wiki_update.py 2 2>&1');

You also might try specifying absolute path - the ~ alias changes based on current user (which is the web server's user, not yours).

Sign up to request clarification or add additional context in comments.

2 Comments

You need the absolute filepath. On my system, ~/Sites/script.py is the same as /Users/jeffstephens/Sites/script.py. You can use pwd on the command line to get the full path!
What did you try? Paste your shell call here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.