on RPI headless lighttp+matchbox+midori not exec bash script

Asked by emilio defranco

on RPI b+ kernel 4.1.18+ with minibian 2016 jessie headless (installed only minimal X and minimal dependencies for running it) with X.Org X Server 1.18.4, matchbox-window-manager 1.2 and midori 0.5.11 compiled on the rpi, I have problems to execute bash script loading php page.

I have a main page were I click on a link and load a php page were I execetute a bash script and reload the main page as down:

<?php
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
exec("/var/www/spegni_d");
sleep(5);
header('Location: http://10.0.50.157//comandi6.htm');
?>

This php code is regularly called from the link but the exec is execute only first time.

After the first, everi time I click on the link, the php page is called but the exec is skipped and i execute only the header location ...

I put on the php page the header for non caching it because I was think that the problem may be was the cache.

If I connected from another pc with midori to the rpi web server, all working fine: the problem is relative only to midori on the RPI when I click the link by RPI midori.

The link on RPI midori exec bash script only one time and reloding the page not resolv: the link run again tha bash script only one time after a long time from the first click.

Ideas ?

Emilio Trieste IT

Question information

Language:
English Edit question
Status:
Expired
For:
Midori Web Browser Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
emilio defranco (e-defranco) said :
#1

update ...

After more investigation is result that the problem is bash script related:

#!/bin/bash

#
# spegne lo schermo del display
#

/bin/sleep 1
#/usr/bin/xset -display :0 s activate
/bin/sleep 2
echo "***" `date` "-- eseguito spegni_d" >> /var/log/spegni_d.log
exit 0

The scope of the script is blanking screen (I am using official RPI touch screen) clicking a button on the web page.

If I comment the function as up reported, all working fine: the script is execute every time, but if comment out the row /usr/bin/xset -display :0 s activate the script is execute only first time and after is skipped (I debug this because I don't found in the log the row echoed).

Emilio

Revision history for this message
emilio defranco (e-defranco) said :
#2

I'm confused: it seems that midori does not execute the exec command.

After further investigations this is my conclusion: is a midori bug.

I explain:

I have written another script and set correctly the permission with visudo for the user www-data.

1) this is the code in main html page for call javascript:

(is a part of a table)
<td><button id="luminosita_meno" style="height: 45px; width: 80px; Font-size: 10px; padding: 1px 1px; border-radius: 2px;"><center>Tablet LUM -<center></button></td>

2) this is the javascript code that call php page for execute bash:

document.querySelector('#luminosita_meno').addEventListener('click', function(e) {
       alert("eseguiro menolum.php");
       window.location.assign("menolum.php");
       alert("ho eseguito menolum.php");
    }, false);

3) this the php code for call bash script:

<?php
sleep(1);
exec("/usr/bin/sudo /usr/local/bin/lum_meno");
sleep(5);
$now=time();
$file="/var/log/lum_meno.log";
$mio= $now . " eseguito lum_meno " . "\n";
file_put_contents($file, $mio, FILE_APPEND | LOCK_EX);
header('Location: http://10.0.50.157/comandi6.htm');
?>

4) the bash script:

#!/bin/bash

#echo $USER >> /var/log/lum_meno.log
attuale=`cat /sys/class/backlight/rpi_backlight/brightness`

if [ "$attuale" -gt 0 ]; then
   attuale=`expr "$attuale" - 15`
   echo "$attuale" > /sys/class/backlight/rpi_backlight/brightness
fi

exit 0

I observed that connecting me with midori from a PC in the network on the RPI server, everything works regularly, while locally on the RPI, midori shows me both the alerts and does not load the php page (should show the first alert, run the redirect and, show the second alert, as it happens on the midori in the network, and instead it does not).

Conclusion: probably midori bug on arm platform.

Revision history for this message
emilio defranco (e-defranco) said :
#3

Ok, is not a problem of midori but of WebKitGTK+.

I have tried another browser based on WekKitGTK+ (surf, http://surf.suckless.org/ very good browser for embedded application with touch screen) and the behavior is the same !

I have also tried another browser based on QtWebKit (qupzilla, https://qupzilla.com) and all working fine !

Qupzilla is more "fat" of midori and of surf and require the installation of many Qt library packages, but working well.

No more responsive at startup and executing some javascript first time, but when cached, is very very quickly ... but qupzilla in my experience is no more suggeted for embedded use with a touch screen because, also in fullscreen mode, if you touch in certain points, it show address bar and menu.

Revision history for this message
Launchpad Janitor (janitor) said :
#4

This question was expired because it remained in the 'Open' state without activity for the last 15 days.