• Benvenuti su RaspberryItaly!
Benvenuto ospite! Login Login con Facebook Registrati Login with Facebook


Valutazione discussione:
  • 0 voto(i) - 0 media
  • 1
  • 2
  • 3
  • 4
  • 5

[-]
Tags
pagina cgi bin realizzare

[Problema] Realizzare pagina cgi-bin
#1
Buongiorno a tutti,
premesso che non ne capisco niente di queste cose.......

Vorrei realizzare un'interfaccia web per l'impostazione di alcuni parametri del Raspberry (tipo indirizzo IP, etc. etc.).
Attualmente stavo lavorando su di una pagina che mi permetta di eseguire alcuni comandi.

Codice:
#!/bin/sh echo "Content-type: text/html" echo "" echo "<HTML>" echo "<HEAD><TITLE>WebMon</TITLE></HEAD>" echo "<BODY bgcolor=\"white\">" #<H1><center>Benvenuto in WebMon</center>" if [ "$REQUEST_METHOD" = "GET" ]; then        Cros=$(echo "$QUERY_STRING")    echo "QUERY_STRING = [$Cros]"        echo "<br>"        if [ -z "$QUERY_STRING" ];      then                # nessun comando, pagina principale                echo "<H2><center>Comandi disponibili</center></H2>"        #       echo "<tr><td><input type=button value=Reboot onclick=location.href='./execute.cgi?reboot'></td><td> Riavvio del sistema operativo</td>"        #       echo "<br><br>"        #       echo "<tr><td><input type=button value=Poweroff onclick=location.href='./execute.cgi?poweroff'></td><td> Shutdown del sistema operativo</td>"                echo "<tr><td><input type=button value=Data onclick=location.href='./commands.cgi?date'></td><td> Visualizza data</td>"                echo "<br>"                echo "<tr><td><input type=button value=Shutdown onclick=location.href='./commands.cgi?poweroff'></td><td> Spegnimento del sistema</td>"                echo "<br>"                echo "<tr><td><input type=button value=Reboot onclick=location.href='./commands.cgi?reboot'></td><td> Riavvio del sistema</td>"                echo "<tr><td><input type=button value=Chi onclick=location.href='./commands.cgi?chi'></td><td> Who</td>"        else                echo "comando ricevuto: '$Cros'"                echo "<br>"                if [ "$Cros" = "date" ]; then                        echo "richiesta comando 'date'"                        echo "<br>"                        date                fi                if [ "$Cros" = "poweroff" ]; then                        echo "richiesta comando 'poweroff'"                        echo "<br>"                        sudo halt                fi                if [ "$Cros" = "reboot" ]; then                        echo "richiesta comando 'reboot'"                        echo "<br>"                        sudo reboot                fi                if [ "$Cros" = "chi" ]; then                        echo "richiesta comando 'chi'"                        echo "<br>"                        who                fi        fi        #echo "<H2><center>Comandi disponibili</center></H2>"        #               echo "<CENTER><b>"        #       echo "<tr><td><input type=button value=Reboot onclick=location.href='./reboot.cgi'></td><td> Riavvio del sistema operativo</td>" else        echo "<title>456 Wrong Request Method</title>"    echo "</head><body>"    echo "<h1>456</h1>"    echo "<p>Requesting data went wrong.<br>The Request method has to be \"GET\" only!</p>" fi echo "</BODY></HTML>"

A questo punto mi compare la pagina web, http://192.168.83.247/cgi-bin/commands.cgi.
Clicco il pulsante "Data" e mi compare la data alla pagina http://192.168.83.247/cgi-bin/commands.cgi?date.

Ovviamente se utilizzo il pulsante "Reboot" il Raspberry mi effettua il reboot ogni volta che accedo alla pagina.
Come si risolve?
Grazie.
Risposta
  


Vai al forum:


Navigazione: 1 Ospite(i)
Forum con nuovi Post
Forum senza nuovi post
Forum bloccato
Forum Redirect