LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices

Reply
 
Search this Thread
Old 11-26-2005, 01:37 PM   #1
mvo
Member
 
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 01:38 PM.
 
Old 11-26-2005, 04:26 PM   #2
jailbait
Guru
 
Registered: Feb 2003
Location: Blue Ridge Mountain
Distribution: Debian Wheezy, Debian Jessie
Posts: 7,531

Rep: Reputation: 178Reputation: 178
"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 ;
then
start some applications
fi

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

dig
echo $?

See:
man dig


----------------------
Steve Stites

Last edited by jailbait; 11-26-2005 at 04:40 PM.
 
Old 11-26-2005, 06:32 PM   #3
Electro
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.
 
  


Reply


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 03:43 AM
connection speed's, what do I need to check ? bigjohn Linux - Networking 3 12-12-2003 02:04 AM
Check connection speed chii-chan Linux - Newbie 1 09-24-2003 12:29 PM
How to check kernel (RH9) is support for Internet connection sharing?? TYLin Linux - Hardware 0 06-18-2003 02:39 AM
How to Check the IP configuration of your Ethernet Connection scottpioso Linux - Networking 3 03-10-2003 11:23 AM


All times are GMT -5. The time now is 03:18 AM.

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