Дело было вечером, делать было нечего.
Запускается как CGI
Bash | 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
| #!/bin/bash
echo -e "Content-type: text/html; charset=utf-8"
echo
A=`echo "$QUERY_STRING" | grep -oE "(^|[?&])a=[0-9]+" | cut -f 2 -d "=" | head -n1`
B=`echo "$QUERY_STRING" | grep -oE "(^|[?&])b=[0-9]+" | cut -f 2 -d "=" | head -n1`
DO=`echo "$QUERY_STRING" | grep -oE "(^|[?&])do=[0-9]+" | cut -f 2 -d "=" | head -n1`
echo -n '<input type="text" value="'
if [ ! -z $A ]; then
if [ ! -z $B ]; then
if [ ! -z $DO ]; then
case $DO in
'0')
result=$(($A + $B))
echo -n $result
;;
'1')
result=$(($A - $B))
echo -n $result
;;
*)
echo -n 'Null'
;;
esac
fi
fi
fi
echo '" disabled>'
echo '<fieldset>'
echo '<form method="get" action="sh.sh">'
echo '<input type="number" name="a" min="0" value="0">'
echo '<fieldset><legend>Операция</legend>'
echo '<input type="radio" name="do" value="0" id="action_plus" checked><label for="action_plus">+</label><br>'
echo '<input type="radio" name="do" value="1" id="action_minus"><label for="action_minus">-</label><br>'
echo '</fieldset>'
echo '<input type="number" name="b" min="0" value="0">'
echo '<br><input type="submit" value="=">'
echo '</form>'
echo '</fieldset>' |
|
|