ShellScripts

From KiSS DP 558 STAGE2 WiKi
Jump to: navigation, search

What is CGI ?

CGI/1.1

The Common Gateway Interface (CGI) is a standard for interfacing external applications with information servers, such as HTTP or Web servers. A plain HTML document that the Web daemon retrieves is static, which means it exists in a constant state: a text file that doesn't change. A CGI program, on the other hand, is executed in real-time, so that it can output dynamic information.

  • Read more about CGI here
  • And the Wiki pages here

CGI scripting

Always start your CGI script, with the following 3 lines.

#!/bin/hush
echo Content-type: text/html
echo

Switching KiSS to audio out and power on

tisiman has started a project about Switching KiSS to oudio out and power on for trying to change to audio multiplexer from Scart2->Scart1 (standby mode) to Kiss->Scart1 (Operating mode).

Missing code

CGI scrips about playlists

mhd has started a project about playlists

Missing code

CGI-Scripts for martinb-fw 1.1.4 (Backup/Restore)

PatPowerMan has started a project about a Backup/restore script for Stage2.

Do we have this code Martin?

MediaPlayer

We can start the MediaPlayer with a cgi script.

  1. Command to execute is: "MediaPlayer MP3 /hdd/audio/test.mp3"
  2. Other commands can be:
    1. "MediaPlayer VOB /hdd/pvr/test.vob"
    2. "MediaPlayer AVI PCLINK1:192.168.20.1:8000:/kissroot/film.vob"
    3. "MediaPlayer SHT icecast://64.236.34.4:80/stream/2009"

Weather example script (justy090)

Read here for more info about this script,

#!/bin/hush 
# 
echo Content-type: text/html 
echo 
cd /hdd/stage2/htmlroot/kml/vreme/ 
wget -O vreme.htm http://x4.x2.1x9.3/vremevsezani/ 
sed -n '158,168p' vreme.htm > rrr.ttt 
rm clear.txt 
echo -n "Datum:" >> clear.txt | grep Datum rrr.ttt | ./cut -d ">" -f 5 | ./cut -d "<f1>> clear.txt 
sleep 1 
klcd 1 
echo -n "Cas:" >> clear.txt | grep Datum rrr.ttt | ./cut -d ">" -f 9 | ./cut -d "<f1>> clear.txt 
sleep 1 
klcd 2. 
echo -n "Temperatura: " >> clear.txt | grep Temperatura rrr.ttt | ./cut -d ">" -f 4 | ./cut -d "<f1>> clear.txt 
sleep 1 
klcd 3.. 
echo -n "Vlaga: " >> clear.txt | grep Vlaga rrr.ttt | ./cut -d ">" -f 3 | ./cut -d "<f1>> clear.txt 
sleep 1 
klcd 4... 
echo -n "Rosisce: " >> clear.txt | grep Rosi rrr.ttt | ./cut -d ">" -f 3 | ./cut -d "<f1>> clear.txt 
sleep 1 
klcd 5.... 
cat /hdd/stage2/htmlroot/kml/vreme/ind2.htm 
echo -n "Pritisk: " >> clear.txt | grep Pritisk rrr.ttt | ./cut -d ">" -f 2 | ./cut -d "<f1>> clear.txt 
sleep 1 
klcd 6..... 
echo -n "Obcutek mraza: " >> clear.txt | grep Ob rrr.ttt | ./cut -d ">" -f 3 | ./cut -d "<f1>> clear.txt 
sleep 1 
klcd 7...... 
echo -n "Veter: " >> clear.txt | grep Veter rrr.ttt | ./cut -d ">" -f 2 | ./cut -d "<f1>> clear.txt 
sleep 1 
klcd 8....... 
echo -n "Smer vetra: " >> clear.txt | grep Smer rrr.ttt | ./cut -d ">" -f 3 | ./cut -d "<f1>> clear.txt 
sleep 1 
klcd 9........ 
sed 's/°//g' clear.txt > source.txt 
klcd 10........ 
./txt2kml.cgi -t -i source.txt -u http://127.0.0.1/kml/index.htm -o index.htm 
klcd 11........ 
cat /hdd/stage2/htmlroot/kml/vreme/index.htm 
exit