Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 11-26-2005, 02:37 PM   #1
Registered: Apr 2005
Location: Delhi, India
Distribution: Mostly Fedora
Posts: 42

Rep: Reputation: 15
check internet connection in .bashrc

I want to start certain applications automatically after login when there is a network /internet connection.

I thought of checking the network connection in .bashrc , but what code should I include to do the job or what other ways could be recommandable?

Cheers, Marcel

Last edited by mvo; 11-26-2005 at 02:38 PM.
Old 11-26-2005, 05:26 PM   #2
LQ Guru
Registered: Feb 2003
Location: Blue Ridge Mountain
Distribution: Linux Mint 17, Debian 8
Posts: 7,865

Rep: Reputation: 311Reputation: 311Reputation: 311Reputation: 311
"I thought of checking the network connection in .bashrc , but what code should I include to do the job or what other ways could be recommandable?"

Issue the dig command and check the return code. A zero return code means that you are connected to the Internet.

if test dig > /dev/null ;
start some applications

I don't know what dig returns when on a network which is not connected to the Internet. You can test the possibilities with:

echo $?

man dig

Steve Stites

Last edited by jailbait; 11-26-2005 at 05:40 PM.
Old 11-26-2005, 07:32 PM   #3
LQ Guru
Registered: Jan 2002
Posts: 6,042

Rep: Reputation: Disabled
The utility dig is only use to verify the setup of DNS servers. The utility wget could be use to check certain servers like mail or other servers. The command below gives an example that you could use.

wget -nv --spider [server address]

Then use the code that it prints out to find out if it has successfully connected to the server.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
.bashrc check if there's a display open sharpie Programming 3 03-31-2004 04:43 AM
connection speed's, what do I need to check ? bigjohn Linux - Networking 3 12-12-2003 03:04 AM
Check connection speed chii-chan Linux - Newbie 1 09-24-2003 01:29 PM
How to check kernel (RH9) is support for Internet connection sharing?? TYLin Linux - Hardware 0 06-18-2003 03:39 AM
How to Check the IP configuration of your Ethernet Connection scottpioso Linux - Networking 3 03-10-2003 12:23 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:05 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration