Hello ,
I am trying to execute a small shell script from a PHP Webpage.
Below is the shell script : 1.sh
$ cat /home/oracle/rahul/1.sh
#!/bin/ksh
echo "`date` : Report generation in progress" > /home/oracle/rahul/report.txt
echo "Run successfully script";
Below is the PHP Script : index1.php and I copied this file in /var/www/html directory
<?php
$old_path = getcwd();
chdir('/home/oracle/rahul/');
$output = shell_exec("sh 1.sh");
echo "<pre>$output</pre>";
chdir($old_path);
?>
When I am trying to run the PHP Script from the command line using : php index1.php then it is executing fine and generating the Output file : /home/oracle/rahul/report.txt however when I am trying to run the url i.e : IPADDRESS/index1.php then it is having problem and I an not able to see anything on my browser.