StatusR

I love the command line interface..I love the terminal. i wanted to create a script that runs after login on my ubuntu machine and do something or show something interesting -at least to me- so I started thinking of something I can do with a script that will show information that I might find it useful.

StatusR

The main idea of this bash script is to get and show status report quickly on weather, Internet status, Google DNS status, OpenDNS status, Internet threat level, and space weather. Possibly other information in the future.
it could be altered easily to show more or less.

its great for fun and can be really useful. Its also a great way to learn about bash script. 
here is the code

#!/bin/bash

#########################################################
# The main idea of this bash script is to #
# get and show status report quickly on #
# Weather, Internet threat level, and Space #
# Weather. Possibly other information in the #
# future. #
# It could be altered easily to show more or #
# less. #
#########################################################
# https://sourceforge.net/projects/statusr
# originally written by: Mohamed Adel
# e-mail: mohamedation[at]gmail[dot]com

# this v2 is a minor edit which removes the clear
# commands in order to use the script as a 
# startup script and leaves the info infront 
# of you.


clear
echo '
  ____  _        _             ____  
 / ___|| |_ __ _| |_ _   _ ___|  _ \ 
 \___ \| __/ _` | __| | | / __| |_) |
  ___) | || (_| | |_| |_| \__ \  _ < 
 |____/ \__\__,_|\__|\__,_|___/_| \_\
                                                                                                                                                                                     
'
command -v lynx >/dev/null 2>&1 || { echo >&2 "I require lynx but it's not installed. Please, install lynx first.  Aborting."; exit 1; }
echo $(date)
echo -e "\033[1mHello, $USER. Here are the Current Reports.\033[0m"
sleep 1
echo -e "\033[1mInternet Status\033[0m"

echo -e '\033[1mInternet Connection status\033[0m'
wget -q --tries=10 --timeout=20 -O - http://google.com > /dev/null
if [[ $? -eq 0 ]]; then
        echo -e "\e[32mOnline\e[0m"
else
        echo -e "\e[31mOffline\e[0m"
fi

echo -e '\033[1mGoogle DNS status\033[0m'
ping  -c 1 -W 10  8.8.8.8 > /dev/null
if [[ $? -eq 0 ]]; then
        echo -e "\e[32mOnline\e[0m"
else
        echo -e "\e[31mOffline\e[0m"
fi

echo -e '\033[1mOpenDNS status\033[0m'
ping  -c 1 -W 10  208.67.222.222 > /dev/null
if [[ $? -eq 0 ]]; then
        echo -e "\e[32mOnline\e[0m"
else
        echo -e "\e[31mOffline\e[0m"
fi

echo -e '\033[1mInternet threat level\033[0m'
lynx -dump "http://isc.sans.edu/infocon.txt"
lynx -dump "http://www.securelist.com/en/alerts" | grep 'Internet threat level:'
lynx -dump "http://www.symantec.com/security_response/threatcon" | grep 'The ThreatCon is currently'

sleep 1

echo ''
echo -e "\033[1mWeather\033[0m"
lynx -dump "http://weather.noaa.gov/weather/current/HECA.html" | grep --after-context=5 "Wind "
sleep 1

echo ''

echo ''
echo -e "\033[1mSpace Weather\033[0m"
lynx -dump "http://spaceweather.com/" | grep  --after-context=2 'Solar wind'
# explanation
# http://spaceweather.com/glossary/solarwinddata.html
lynx -dump "http://spaceweather.com/" | grep  --after-context=2 'X-ray Solar Flares'
# explanation
# http://spaceweather.com/glossary/flareclasses.html
sleep 1
echo ''
echo 'Have a great day'
exec /bin/bash

or you can simply visit sourceforge and download it from there


please feel free to try it, change it, and share it...hit me @mohamedation on twitter if you have something to say.

Comments

Popular posts from this blog

تخيلات - عبيد

لو كنت تعرفني بجد