Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php run shell script

Tags:

bash

php

I'm trying to run a shell script from a php frontend

heres the shell file (run.sh chmod to 777)

#!/bin/bash
wget -O index.html http://markets.usatoday.com/custom/usatoday-com/html-mktscreener.asp
python hw7-9.py index.html 
echo "done";

Heres the php front end

<?php
   $output = shell_exec("run.sh");
   echo "<pre>$output</pre>";
?>

But it php page doesn't return anything except

<pre></pre>
like image 983
Kamran224 Avatar asked Dec 07 '11 18:12

Kamran224


2 Answers

Have you tried doing error_reporting(-1); at the top of your PHP script. Likely shell_exec is disabled on your server.

like image 170
Mike Avatar answered Oct 05 '22 03:10

Mike


Would you try $output = shell_exec("sh run.sh");

like image 25
Nitesh Avatar answered Oct 05 '22 02:10

Nitesh