Shell Script to check internet connection status from Linux

July 5, 2016 | By | Reply More

In case you need a shell script that can be used to check your internet connection via console, the following script lines could be your friend. The shell script below will perform a wget connection to google with several tries and then returned the value as online or offline string.

If you are new to Shell script, you can follow these steps to create a simple shell script/program. I assume you are able to use nano (actually you may use any other text editor you like such as vi).

Create a new shell script file called check-internet.sh

Next, paste those code above to the new file

check internet connection script

Now save the file and exit. CTRL + X is used if you are using nano to edit the file.

Now make the file executable

Finally run the program

Output

 

Tags: , ,

Category: Programming, Script

Leave a Reply