summaryrefslogtreecommitdiff
path: root/get_temps.sh
diff options
context:
space:
mode:
Diffstat (limited to 'get_temps.sh')
-rwxr-xr-xget_temps.sh41
1 files changed, 41 insertions, 0 deletions
diff --git a/get_temps.sh b/get_temps.sh
new file mode 100755
index 0000000..ca81aa5
--- /dev/null
+++ b/get_temps.sh
@@ -0,0 +1,41 @@
1#!/bin/bash
2
3USER="temps"
4HOST="172.16.0.101"
5PASSWORD=""
6
7COMMAND=$1
8ARGUMENT=$2
9DEVICE=$3
10
11function get_temps {
12( expect | grep -A 9 "Max_Temp" | grep "^[0-9]" ) <<EOF
13 spawn ssh -l $USER $HOST
14 expect "password: "
15 send "$PASSWORD\n"
16 expect -re ".*>"
17 send "show environment\n"
18 expect -re ".*>"
19 send "exit\n"
20 exit
21EOF
22}
23
24# C to F
25# echo "scale=1; $(get_temps | grep $DEVICE | awk '{ printf("%d", $4) }') * 9/5 + 32" | bc
26
27if [[ $COMMAND == "index" ]]; then
28 get_temps | awk '{ print $3 }'
29elif [[ $COMMAND == "get" ]]; then
30 if [[ $ARGUMENT == "max" ]]; then
31 get_temps | grep $DEVICE | awk '{ printf("%d", $6) }'
32 elif [[ $ARGUMENT == "temp" ]]; then
33 get_temps | grep $DEVICE | awk '{ printf("%d", $4) }'
34 fi
35elif [[ $COMMAND == "query" ]]; then
36 if [[ $ARGUMENT == "max" ]]; then
37 get_temps | awk '{ print $3 ":" $6 }'
38 else
39 get_temps | awk '{ print $3 ":" $4 }'
40 fi
41fi