LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices

Reply
 
Search this Thread
Old 07-09-2008, 03:30 PM   #1
DragonM15
Member
 
Registered: Sep 2003
Location: USA
Distribution: Slackware (Multiple Versions)
Posts: 455

Rep: Reputation: 31
test to see if eth0 is active


Ok, heres the deal. I am making a bash script that checks to see if the ip address is in a certain range, and proceeds to backup data to a server. I did this by grepping ifconfig for a certain ip range. However this script is going to be ran on a laptop that will be plugged and unplugged from the network. If you run ifconfig when the laptop isnt plugged in but the nic is turned on, it keeps the ip address from the last time you ran dhcpcd, even though it isn't plugged in at the time.

What I need is a way to tell if the ethernet cable is plugged in or not. Is there a way to do this?

Thanks,
DragonM15
 
Old 07-09-2008, 03:53 PM   #2
farslayer
Guru
 
Registered: Oct 2005
Location: Willoughby, Ohio
Distribution: linuxdebian
Posts: 7,231
Blog Entries: 5

Rep: Reputation: 189Reputation: 189
possibly with ethtool ..

it-etch:/# ethtool eth0 | grep Link
Link detected: yes
 
Old 07-09-2008, 04:00 PM   #3
DragonM15
Member
 
Registered: Sep 2003
Location: USA
Distribution: Slackware (Multiple Versions)
Posts: 455

Original Poster
Rep: Reputation: 31
That was exactly what I was looking for. Works like a charm! Thanks for your quick reply.

DragonM15
 
  


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
Eth0 is not active after boot toes Linux - Wireless Networking 3 07-23-2006 04:34 PM
Cannot ping self ??? eth0 not active ??? Wynand1 Linux - Networking 2 06-29-2006 12:11 AM
howto test if an ethernet device is active six6 Programming 1 01-28-2005 02:39 AM
interface eth0 is not (yet?) active jorcas Suse/Novell 1 11-22-2004 06:53 PM
eth0 not active on startup rocket84 Linux - Networking 6 07-21-2003 01:09 AM


All times are GMT -5. The time now is 05:07 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