-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_status_code.sh
39 lines (30 loc) · 1.12 KB
/
check_status_code.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
#!/bin/bash
# RESULTADO=$(curl -i 'http://www.google.com' | grep HTTP)
# echo $RESULTADO
# [[ $RESULTADO == "HTTP/1.1 200 OK" ]] && echo ok || echo erro
HTTP_CODE=$(curl -o relatorios.txt -L -s -w "%{http_code}" http://www.google.com)
function check_status_code() {
if [ "$HTTP_CODE" == "200" ]; then
echo "=================================================="
echo "operando servico web"
echo "Serviço Online"
echo "=================================================="
else
echo "=================================================="
echo "Serviço Offline"
echo "=================================================="
fi
}
function available_internete(){
if : >/dev/tcp/8.8.8.8/53; then
echo "=================================================="
echo 'Internet available.'
echo "=================================================="
else
echo "=================================================="
echo 'Offline.'
echo "=================================================="
fi
}
check_status_code
available_internete