-
Notifications
You must be signed in to change notification settings - Fork 0
/
list_instances.sh
56 lines (51 loc) · 1.1 KB
/
list_instances.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
51
52
53
54
55
56
#/bin/bash
read_list()
{
local src_file=$1
local line=""
base_cnt=0
while IFS= read -r line
do
if [[ ! "$line" = "" ]]
then
base_list[${base_cnt}]=$(printf '%s\n' "$line")
# echo ${base_list[${base_cnt}]}
base_cnt=$((base_cnt+1))
fi
done <"$src_file"
if [ $base_cnt -eq 0 ]
then
echo "[-] Error: No se encontraron bases en el archivo: $base_list_file"
exit 2
fi
}
fetch_instances()
{
gcloud compute instances list| grep RUNNING > /dev/shm/instances
local src_file=$$1$$111
local line=""
base_cnt=0
while IFS= read -r line
do
if [[ ! "$line" = "" ]]
then
base_list[${base_cnt}]=$(printf '%s\n' "$line")
# echo ${base_list[${base_cnt}]}
base_cnt=$((base_cnt+1))
fi
done <"$src_file"
if [ $base_cnt -eq 0 ]
then
echo "[-] Error: No se encontraron bases en el archivo: $base_list_file"
exit 2
fi
}
gcloud compute instances list| grep RUNNING > /dev/shm/instances
exec 3<> /dev/shm/instances
while read str_line <&3
do
{
echo $str_line
}
done
exec 3>&-