-
Notifications
You must be signed in to change notification settings - Fork 2
/
send_command_direct_IP.sh
54 lines (35 loc) · 1.04 KB
/
send_command_direct_IP.sh
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
#!/bin/sh
# This program can send command to Sony Bravia TV pre-android mnufactured between 2011-2013 with Direct IP commands
set -e
if [ "$1" = "" ] || [ "$2" = "" ]; then
echo "Usage: $0 <TV_IP> <IP_COMMAND>"
exit 1
fi
if code=$(echo | http --check-status --ignore-stdin --pretty format --headers --follow --timeout 3600 GET ''$2'');
then
# we cut number from header answer
code2=$(echo $code | cut --delimiter=' ' --fields=2)
#echo $code2
#checking if communicate is with correct number
echo ""
if [ $code2 = "200" ]; then
echo "✓"
echo ""
#echo $code3
else
echo " ⃠"
echo ""
echo "Command failed (HTTP_CODE: $code, try running it in a console)"
echo ""
fi
else
echo ""
case $? in
2) echo 'Request timed out!' ;;
3) echo 'Unexpected HTTP 3xx Redirection!' ;;
4) echo 'HTTP 4xx Client Error!' ;;
5) echo 'HTTP 5xx Server Error!' ;;
6) echo 'Exceeded --max-redirects=<n> redirects!' ;;
*) echo 'Other Error!' ;;
esac
fi