-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathma
53 lines (50 loc) · 1.11 KB
/
ma
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
#!/bin/bash
A=({2..26})
E=({27..51})
F=({52..76})
ET=({77..100})
while getopts ':f:c:hv' OPTION; do
case "$OPTION" in
f)
classroom="${OPTARG^^}[@]"
;;
c)
comm="$OPTARG"
;;
h)
echo "Usage: $(basename $0) [-v] [-h] [-f name] [-c 'command']" >&2
exit 0
;;
v)
echo 'MA-MA MASIVO.' >&2
echo 'Command line utility for massive working. Version 0.2' >&2
exit 0
;;
:)
echo "Missing argument for $OPTARG" >&2
echo "Usage: $(basename $0) [-v] [-h] [-f name] [-c 'command']" >&2
exit 2
;;
?)
echo "Invalid flag." >&2
echo "Usage: $(basename $0) [-v] [-h] [-f name] [-c 'command']" >&2
exit 2
;;
esac
done
if [[ "$comm" ]] && [[ "$classroom" ]]; then
for i in "${!classroom}"; do
pc=159.59.9.$i
if ping -c 1 $pc >/dev/null; then
echo "Running '${comm}' in $pc."
ssh root@$pc "${comm}"
echo
else
echo "$pc is off."
fi
done
else
echo "Missing some argument in the script." >&2
echo "Usage: $(basename $0) [-v] [-h] [-f name] [-c 'command']" >&2
exit 2
fi