I have a few bash and perl scripts which has been asked to be made executable through a web based interface. Nothing fancy, just for easy access.
PHP seemed to be the quick and dirty solution for the purpose [through exec()
]. So I turned off the safe mode in php.ini and tried
$output = array();
exec('/var/www/vhosts/default/htdocs/scripts/RUN.sh',$OUTPUT);
print_r($output);
var_dump($output);
Now whatever files are accessed in the RUN.sh script (accessed though a relative path) are not found. Is there any way of getting this to work without giving complete path to every single redirect (or any file for that matter) that is being accessed in the scripts?
After applying the accepted solution:
Say one line form the script:
time python idsplitter.py OUTPUT/TMP/tokens OUTPUT/token_splits
echo "done"
While the time
-s output gets pushed to error_log file, "done" is never passed to the $OUTPUT array. The returned value in the third argument to exec(), when printed on page gives 0
.
Update:
time
command puts it out to stderr so if do `
t=`time some_command 2>&1`
then also nothing gets stored in t. So that makes sense. Thanks for the help everyone ...