Bash program to start downloading a file on int connection.

Damn ISM internet !

We don’t have internet connection till it is 6’O clock evening, and they kill it at 2:30 AM. It’s 4:30 PM and i am waking up from my bed thinking that “What is the time? I have to start the downloading the Youtube java tutorial playlist, still there are 6 videos to download”.

Then it struck to me that “How about writing a bash script to check the internet connection(not LAN connectivity) and start download if it is true”. A wget command, if else condition on wget return and some sleep to the program, BINGO i got the script in my mind  within a couple of minutes.

while true
        wget -q --tries=10 --timeout=20
        if [[ $? -eq 0 ]]; then
                echo "hey dont forget to press CTRL-C when all the downloads are completed, as i am not programmed to do that"
                echo "any way my developer is still trying to improve this issue"
                youtube-dl --playlist-start=11 ""
                echo "there is no internet connection ! so i am starting the download"
                echo "---------------------------------------------------------------"
        sleep 2


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s