-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprendidos.sh
More file actions
executable file
·45 lines (43 loc) · 1.02 KB
/
prendidos.sh
File metadata and controls
executable file
·45 lines (43 loc) · 1.02 KB
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
#!/bin/bash
if [ $# -eq 0 ]; then
echo "" > temp_apagados
echo "sin parametros - viendo todos los pc"
$0 pcs/lpa
echo ""
echo ""
echo "" >> temp_apagados
echo "" >> temp_apagados
$0 pcs/lds
echo ""
echo "Resumen - pcs apagados"
echo "$(cat temp_apagados)"
rm temp_apagados
exit 1
fi
if [ $# -gt 2 ]; then
echo "usar: $0 LISTA_DE_COMPUTADORES [-a]"
exit
fi
ap="prendidos"
if [ $# = 2 ]; then
if [ $2 = "-a" ]; then
ap="apagados"
fi
fi
if [ -f $1 ]; then
for pc in $(cat $1 | grep -v "^#")
do
compu=$(ping -w 1 $pc | grep "bytes from")
if [ "x${compu}" != 'x' ]; then
if [ $ap != "apagados" ]; then
echo -e "\e[0;32m$pc PRENDIDO\e[0m"
ssh -o ConnectTimeout=3 root@$pc "users"
fi
else
echo -e "\e[1;31m$pc APAGADOH\e[0m"
echo -e "\e[1;31m$pc APAGADOH\e[0m" >> temp_apagados
fi
done
else
echo "La lista no es una lista valida de PeCes"
fi