I need to execute a shell script through php. I am using Apache web server to run my php pages.
Here is my php file:
<?php
$output = shell_exec('sh /usr/local/hadoop-3.0.2/copytoallhdfs.sh');
echo "<pre>" . $output . "</pre>";
?>
Here is my shell script copytoallhdfs.sh:
#!/bin/bash
myarray=`bin/hdfs dfs -ls -C /`
echo $myarray;
for name in $myarray
do bin/hdfs dfs -copyFromLocal myData/* $name;
done
My copytoallhdfs.sh script is located on the path /usr/local/hadoop-3.0.2 . So normally php should be executing my shell script and displaying the output of echo $myarray; on the web server, but nothing is displaying on my browser.
Maybe it is some permissions problems or something missing in my php.ini but i just can't solve this problem.
Can anyone please give me a work around for this.
Thank you.