Progetto

Generale

Profilo

Wiki » setchannel.sh

Script per il Submit della singola stazione - Andrea Belloni, 03-12-2014 17:11

 
1
#!/bin/sh
2

    
3
decode(){
4
echo $QUERY_STRING |\
5
   sed 's/+/ /g'| sed 's/\%0[dD]//g' |\
6
   awk '/%/{while(match($0,/\%[0-9a-fA-F][0-9a-fA-F]/))\
7
     {$0=substr($0,1,RSTART-1)sprintf("%c",0+("0x"substr(\
8
      $0,RSTART+1,2)))substr($0,RSTART+3);}}{print}'
9
}
10

    
11
TMP1=$( decode )
12
TMP=${TMP1%&name*}
13
CHAN=${TMP%=http*}
14
CHANLEN1=`expr length $CHAN + 1`
15
URL=${TMP:$CHANLEN1}
16
NAMEKV=`expr "$TMP1" : '.*\(name.*\)'`
17
NAMEK=${NAMEKV%=*}
18
NAMEKLEN1=`expr length $NAMEK + 1`
19
NAMEV=${NAMEKV:$NAMEKLEN1}
20

    
21
uci set radio.@radio[0].$CHAN=$URL
22
uci set radio.@radio[0].$NAMEK=$NAMEV
23

    
24
BLA='#####################'
25
NM=${NAMEV:0:19}
26
NMLEN=`expr length $NM`
27
NML19=`expr 19 - $NMLEN`
28
BLA19=${BLA:0:$NML19}
29
C=${CHAN:2}
30
C1=`expr $C - 1`
31
C1LEN=`expr length $C1`
32
if [ "$C1LEN" -eq "1" ]
33
then
34
  SER="AB"$NM$BLA19"0"$C1
35
else
36
  SER="AB"$NM$BLA19$C1
37
fi
38
echo $SER > /dev/ttyS0
39
#echo $SER
40

    
41
echo 'Content-type: text/html'
42
echo
43

    
44
echo '<head>'
45
echo '<meta http-equiv="Refresh" content="0;url=http://192.168.1.42/cgi-bin/radio.cgi" />'
46
echo '</head>'
47
echo '<html><body>'
48
#echo "$SER"
49
#echo '<br>'
50
#echo "Setting Channel $CHAN to station $URL"
51
#echo '<br>'
52
#echo "Setting Channel $NAMEK to station $NAMEV"
53
echo '</body></html>'
(4-4/6)