LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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
LQ Guru
 
Registered: Feb 2003
Location: Virginia, USA
Distribution: Debian 12
Posts: 8,340

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
"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
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.
 
  


Reply



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:56 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration