forked from km4ack/pi-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
getcall
90 lines (70 loc) · 2.85 KB
/
getcall
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/bash
#Call sign lookup for raspberry pi
#20200416 km4ack
#20200610 last edit
#comment out anything that involves calling n0agi server
#for lookup because it often returns busy and gives no results
LOOKUP(){
CALL=$(yad --center --width=200 --wrap --window-icon=$HOME/Pi-ISS/ISS.png --title="Call Sign Lookup" --text="<b>Call Sign Lookup</b> \r by KM4ACK" --text-align=center \
--form --separator="|" --item-separator="," \
--field="Callsign to Lookup" ''
)
BUT=$?
if [ $BUT = 1 ] || [ $BUT = 252 ]; then
exit
fi
#timer window while wait on first curl command
yad --width=300 --height=75 --title="Sending" --timeout=2 --timeout-indicator=top --no-buttons --center --text="Getting Data" &
#USCALL=$(echo $CALL | awk -F "|" '{print $2}')
CALL=$(echo $CALL | awk -F "|" '{print $1}')
CALL1=$CALL
#section commented out due to n0agi server failures
#if [ $USCALL = "TRUE" ]; then
#look up US call on N0AGI server
#LOOKCALL=$(curl -s https://call3.n0agi.com/$CALL/p/)
#CALL=$(echo $LOOKCALL | awk -F "|" '{print $1}' | sed 's/<CALL>//')
#CLASS=$(echo $LOOKCALL | awk -F "|" '{print $2}')
#NAME=$(echo $LOOKCALL | awk -F "|" '{print $10" "$11" "$12}')
#ADDRESS=$(echo $LOOKCALL | awk -F "|" '{print $13}')
#CITY=$(echo $LOOKCALL | awk -F "|" '{print $14" "$15","$16}')
#EXPIRE=$(echo $LOOKCALL | awk -F "|" '{print $24}')
#yad --center --width=350 --wrap --window-icon=$HOME/Pi-ISS/ISS.png --title="Call Sign Lookup" --text="<b>Call Sign Lookup</b> \r by KM4ACK" --text-align=center \
#--form --separator="|" --item-separator="," \
#--field="Callsign":RO "$CALL" \
#--field="Class":RO "$CLASS" \
#--field="Name":RO "$NAME" \
#--field="Address":RO "$ADDRESS" \
#--field="City ST ZIP":RO "$CITY" \
#--field="License Expires":RO "$EXPIRE" \
#--button="Exit:1" \
#--button="Lookup Another:2"
#BUTTON=$?
# if [ $BUTTON = 1 ] || [ $BUTTON = 252 ]; then
# exit
# fi
#else
yad --width=300 --height=75 --title="Sending" --timeout=2 --timeout-indicator=top --no-buttons --center --text="Getting Data" &
FILE=/run/user/$UID/call.txt
curl -s -k https://hamcall.net/call?callsign=$CALL1 | grep "</table>" -A 4 -m3 | tail -4 > $FILE
NAME=$(cat $FILE | head -1 | sed 's/<B>//' | sed 's/<br>//' | awk -F "," '{print $1}')
CALL=$(cat $FILE | head -1 | sed 's/<B>//' | sed 's/<br>//' | awk -F "," '{print $2}')
CITY=$(cat $FILE | head -3 | tail -1 | sed 's/<br>//')
COUN=$(cat $FILE | head -4 | tail -1 | sed 's/<br>//')
rm $FILE
yad --center --width=350 --wrap --window-icon=$HOME/Pi-ISS/ISS.png --title="Call Sign Lookup" --text="<b>Call Sign Lookup</b> \r by KM4ACK" --text-align=center \
--form --separator="|" --item-separator="," \
--field="Callsign":RO "$CALL" \
--field="Name":RO "$NAME" \
--field="QTH":RO "$CITY" \
--field="Country":RO "$COUN" \
--button="Exit:1" \
--button="Lookup Another:2"
BUTTON=$?
#fi
if [ $BUTTON = 2 ]; then
LOOKUP
elif [ $BUTTON = 1 ] || [ $BUTTON = 252 ]; then
exit
fi
}
LOOKUP