Solved

How To Know If Ethernet Cable Is Attached

Posted on 2007-04-03
9
404 Views
Last Modified: 2008-01-09
I am looking for a way to programmatically tell whether an active ethernet cable is attached to my Linux system. I am running Mandrake Linux, but would like a Linux-neutral solution if there is one. Is there a way to know (programmatically) whether the ethernet port on my Linux system has a cable attached (assuming that the other end of the cable is attached to an active, running ethernet port)?

Thanks,
Dan
0
Comment
Question by:cunningham
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
9 Comments
 
LVL 9

Accepted Solution

by:
kfullarton earned 125 total points
ID: 18846103
Try ethtool....

ethtool eth0
0
 

Author Comment

by:cunningham
ID: 18846326
I think that ethtool is kind of like the thing that I want. I want to be able to do this programmatically, meaning that I want to write a program that checks for ethernet connection activity. How do I do this in a program?
0
 
LVL 9

Expert Comment

by:kfullarton
ID: 18847094
ethtool | grep -i link will tell you if the link is up or down from the local machine.
0
Are You Using the Best Web Development Editor?

The worlds of web hosting and web development are constantly evolving. Every year we see design trends change, coding standards adapt and new frameworks/CMS created. With such a quick pace of change it’s easy to get lost trying to keep up.

See if your editor made the list.

 
LVL 48

Expert Comment

by:Tintin
ID: 18847620
or

mii-tool eth0 | grep -q "link ok"  || echo "eth0 is down"
0
 

Author Comment

by:cunningham
ID: 18850273
I am looking for a way to do this inside a program that I write using the 'C' language. I am not interested in how to do this from the shell (unless it leads me to a way to do it in a program!).
0
 
LVL 2

Assisted Solution

by:mostenscer
mostenscer earned 125 total points
ID: 18854182
Well i hope you know that u can run shell Programs through C programming languages The systax is like
system("ls -la");
you may have to include system.h or so
ofter than u can write the out put to a file and then start readind it from the tail and so on ...................
0
 

Author Comment

by:cunningham
ID: 18857164
I thought that there would be some kind of intrinsic call that I could make without using the 'system' call, but it doesn't look like there is. I'll split the points because it looks like the solution is to use a shell command within the 'system' call.
0
 
LVL 48

Expert Comment

by:Tintin
ID: 18878938
There's no specific system call you can make as it is dependant on many different things.

Have a look at the source of ethtool to get an idea of how to program it in C.
0
 
LVL 2

Expert Comment

by:mostenscer
ID: 18879129
well well come to be world of c:) dowload this pieace of code and read the documention and you will get the answer
http://0pointer.de/lennart/projects/ifplugd/
0

Featured Post

Plug and play, no additional software required!

The ATEN UE3310 USB3.1 Gen1 Extender Cable allows users to extend the distance between the computer and USB devices up to 10 m (33 ft). The UE3310 is a high-quality, cost-effective solution for professional environments such as hospitals, factories and business facilities.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question