Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How To Know If Ethernet Cable Is Attached

Posted on 2007-04-03
9
Medium Priority
?
408 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 500 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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 500 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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

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…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

704 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