/usr/lib/cgi-bin/bash/index.cgi

[Ritorna]

#!/bin/bash # index.cgi # # Copyright (C) 2016 Ing. Stefano Salvi<stefano@salvi.mn.it> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301, USA. echo "Content-Type: text/html;charset=utf-8" echo "" echo '<!DOCTYPE html>' echo '<html lang="it">' echo ' <head>' echo ' <title>Raspberry-My Programmazione come Script di Shell</title>' echo ' <meta name="author" content="Ing. Stefano Salvi">' echo ' <meta charset="utf-8">' echo ' <link rel="stylesheet" type="text/css" href="../../css/index.css">' echo ' <script type="text/javascript" src="../../js/index.js"></script>' echo ' </head>' echo ' <body>' echo ' <!-- Dialog -->' echo ' <div id="isf_overlay">' echo ' <div id="isf_overlay_frame">' echo ' <div id="isf_overlay_content">' echo ' <h2>' echo ' Dialog modale visualizzato dal Javascript' echo ' </h2><p>' echo ' &Egrave; possibile fare comparire un dialog sopra la pagina, che scompaia con un bottone.' echo ' </p>' echo ' </div>' echo ' <div id="isf_overlay_bottom">' echo ' <input id="isf_overlay_close_button" type="button" onClick="closeDialog()" value="Chiudi">' echo ' </div>' echo ' </div>' echo ' </div>' echo ' <!-- Fine Dialog -->' echo ' <!-- Slideshow -->' echo ' <div id="testa-carousel">' echo ' <div id="testa-slideshow">' echo ' <img src="../../img/little_pi.png" alt="Raspberry Pi 3" width="400" height="400" />' echo ' <img src="../../img/raspberry-pi-2-angle-100569133-orig.png" alt="Raspberry Pi 3" width="400" height="400" />' echo ' <img src="../../img/Raspberry_Pi_-_Model_A.jpg" alt="Raspberry Pi Model A" width="400" height="400" />' echo ' <img src="../../img/rpi1bplus.png" alt="Raspberry Pi 2" width="400" height="400" />' echo ' </div>' echo ' </div>' echo ' <!-- Fine Slideshow -->' echo " <script type=\"text/javascript\">var slides = new Slideshow('testa-slideshow', 1000, 400);</script>" echo ' <h1>Esempi di programmazione come Script di Shell</h1>' echo ' <p>[<a href="../../index.html#bash">Ritorna</a>]</p>' echo ' <p><input type="button" onClick="openDialog()" value="Apri Dialog"></p>' echo ' <form method="get" action="index.cgi">' echo ' <p>Primo numero: <input type="text" name="primo"><br>' echo ' Secondo numero: <input type="text" name="secondo"><br>' echo ' <input type="submit" value="Somma"></p>' echo ' </form>' echo ' <br class="clear">' if [ "x$QUERY_STRING" != x ] then primo=`echo $QUERY_STRING | sed -e "s/^.*primo=\([-0-9]*\).*$/\\1/"` secondo=`echo $QUERY_STRING | sed -e "s/^.*secondo=\([-0-9]*\).*$/\\1/"` if [ "x$primo" == x ] then echo ' <div class="error">' echo " <h2>Il Primo numero non pu&ograve; essere vuoto e deve essere un numero</h2>" echo ' </div>' elif [ "x$secondo" == x ] then echo ' <div class="error">' echo " <h2>Il Secondo numero non pu&ograve; essere vuoto e deve essere jun numero</h2>" echo ' </div>' else risultato=`expr $primo + $secondo` echo ' <div class="display">' echo " <h2>$primo + $secondo = $risultato</h2>" echo ' </div>' fi fi echo ' <div class="display">' echo ' <h2>Variabili di sistema</h2>' echo ' <pre>' set echo ' </pre>' echo ' </div>' echo ' <div id="footer">' echo ' <span class="author">Autore Stefano Salvi</span> <a href="mailto:stefano@salvi.mn.it" title="Indirizzo Mail di Salvi">stefano@salvi.mn.it</a>' echo ' Rilasciato su licenza <a href="https://creativecommons.org/licenses/by-sa/3.0/it/legalcode" title="Attribuzione CC-by-sa">CC-BY-SA</a><br>' echo ' <a href="https://creativecommons.org/licenses/by-sa/3.0/it/legalcode" title="Attribuzione CC-by-sa"><img src="../../img/cc_by_sa_88x31.png" alt="Logo Creative Commons" title="Logo Creative Commons"></a>' echo ' </div>' echo ' </body>' echo '</html>'