-
Notifications
You must be signed in to change notification settings - Fork 10
/
ubnt-edge-switch-poe-on-off.sh
51 lines (40 loc) · 1.26 KB
/
ubnt-edge-switch-poe-on-off.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
50
#!/usr/bin/env bash
#
# Usage:
# $ ubnt-edge-switch-poe-on-off.sh 192.168.1.20 1
USR=ubnt
PWD=2rjudoru
IP="$1"
LANPORT="$2"
echo "===== Disable PoE port: ${LANPORT} at ${IP} ====="
# PoE Port Status
nc ${IP} 23 >&1 2>&1 << EOF
${USR}
${PWD}
enable
${PWD}
configure
show poe status 0/${LANPORT}
EOF
# Method 1
#(echo "${USR}"; echo "${PWD}"; echo "enable"; echo "${PWD}"; echo "configure" ; echo "interface 0/${LANPORT}" ; echo "poe opmode shutdown") | nc ${IP} 23
# Method 2
#echo -e ${USR}"\n"${PWD}"\n"en"\n"${PWD}"\n"config"\n"interface 0/${LANPORT}"\n"poe opmode shutdown | nc ${IP} 23
#echo -e "${USR}""\n""${PWD}""\n""enable""\n""${PWD}""\n""config""\n""interface 0/${LANPORT}""\n""poe opmode shutdown" | nc ${IP} 23 > /dev/null 2>&1
# Method 3
nc ${IP} 23 > /dev/null 2>&1 << EOF
${USR}
${PWD}
enable
${PWD}
configure
interface 0/${LANPORT}
poe opmode shutdown
EOF
# Sleep for 500ms
sleep 0.5
echo "===== Enable PoE port: ${LANPORT} at ${IP} ====="
# Method 1
# (echo "${USR}"; echo "${PWD}"; echo "enable"; echo "${PWD}"; echo "configure" ; echo "interface 0/${LANPORT}" ; echo "poe opmode auto") | nc ${IP} 23
# Method 2
echo -e "${USR}""\n""${PWD}""\n""enable""\n""${PWD}""\n""config""\n""interface 0/${LANPORT}""\n""poe opmode auto" | nc ${IP} 23 > /dev/null 2>&1