I am trying to display the output of a bash script to a div on my webpage. But when i load the page nothing appears. Here is what I have so far.
Jquery ajax function. Discon is the name of the div the info is supposed to be appearing in.
$(document).ready(function() {
$.ajax({
type: "POST",
url: "discon.php",
data: "Discontinuities",
success: function(data) {
$('#discon').html(data)
}
});
});
Here is my php to take what is in the jquery. Note the commented out parts are places where i was trying different options in php. I have tried several and nothing seems to work.
<?php
echo passthru('/opt/bin/enc_current_test');
//$discon = exec('/opt/bin/enc_current_test', $o, $r);
//if ($r != 0){
// print 'Error running command';
// exit($r);
//}
//else{
// print implode("\n", $o);
//}
?>
I have another bash script that is displaying to the same page in a different Div and it works fine so my question is why is this one giving me a problem. Here is the bash script.
#!/bin/bash
while [ true ]
do
counter=0
clear
date
dir=/test/`date "+%Y/%m/%d"`
cd $dir
echo Writing On: `pwd`
for i in `ls`
do
if [ -n "$(ls -l $i/* | grep `date "+ %k:%M"`)" ];
then
echo $i
let "counter+=1"
fi
done
echo
echo "Total Current Streams: "
echo $counter
sleep 60
clear
done
I am thinking it is because the script sleeps for 60 seconds, but i added the tag in my html to refresh the page at that same interval and it still does not work. Any idea as to why this script would not display? Kind of at a loss at this point. Thanks for any replies.