For Programmers: Free Programming Magazines  


Home > Archive > Unix Shell Programming > March 2004 > how do you tell if a line is up instead of the card/NIC status?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author how do you tell if a line is up instead of the card/NIC status?
Flip

2004-03-30, 3:40 pm

By doing a ifconfig I'm able to identify if the card is up. However, if
there is no physical wire connected to that card/interface, how do I find
this out at a script level?

Any help would be appreciated. Thank you.


Barry Margolin

2004-03-30, 4:37 pm

In article <gakac.1928$Xy3.7423@tor-nn1.netcom.ca>,
"Flip" <[remove]phenry_w@hotmail.com> wrote:

> By doing a ifconfig I'm able to identify if the card is up. However, if
> there is no physical wire connected to that card/interface, how do I find
> this out at a script level?


I don't think you can -- certainly not portably.

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
Alan Connor

2004-03-30, 4:37 pm

On Tue, 30 Mar 2004 14:46:39 -0500, Flip <> wrote:
>
>
> By doing a ifconfig I'm able to identify if the card is up. However, if
> there is no physical wire connected to that card/interface, how do I find
> this out at a script level?
>
> Any help would be appreciated. Thank you.
>
>


Depends on what OS you are running.

On Debian Linux, the interface doesn't come up unless there is an actual
connection, so /sbin/ifconfig wouldn't show the interface as being up
if the wire wasn't connected.

Trying to run, say, pppd, would fail and the interface wouldn't be created.

Ifconfig doesn't tell you that the card is there except indirectly. But you
can find out if it is from your boot-time messsages.

AC

joe@invalid.address

2004-03-30, 4:37 pm

"Flip" <[remove]phenry_w@hotmail.com> writes:

> By doing a ifconfig I'm able to identify if the card is up.
> However, if there is no physical wire connected to that
> card/interface, how do I find this out at a script level?


One possibility is to run ping in the background aimed at some ip
address on the local network and kill it after a second or so. Then
run arp and see if it gives you an ethernet address for that address
or not.

You probably want to delete all the existing arp entries first, but
that should require root access. Depending on your system, arp may or
may not be willing to delete all entries at once. You may have to read
the entries first and then delete them one by one.

There's probably a better way of doing something like this though.

Joe
--
If people don't want to come out to the ballpark, nobody's going
to stop them.
- Yogi Berra
Rich

2004-03-30, 5:45 pm



In infinite wisdom joe@invalid.address answered:
> "Flip" <[remove]phenry_w@hotmail.com> writes:
>
>
>
>
> One possibility is to run ping in the background aimed at some ip
> address on the local network and kill it after a second or so.


Actually Solaris ping accepts a timeout argument.

% ping <hostname> <seconds>

Since the default timeout is 20 seconds, I usually set it to '1' when
testing, or my scripts can hang for a long time waiting for ping to
timeout.

I'm not sure about Lynux pings. Do they also accept a timeout argument?

Rich


> Then
> run arp and see if it gives you an ethernet address for that address
> or not.
>
> You probably want to delete all the existing arp entries first, but
> that should require root access. Depending on your system, arp may or
> may not be willing to delete all entries at once. You may have to read
> the entries first and then delete them one by one.
>
> There's probably a better way of doing something like this though.
>
> Joe


Chris F.A. Johnson

2004-03-30, 5:45 pm

On Tue, 30 Mar 2004 at 21:39 GMT, Rich wrote:
>
>
> In infinite wisdom joe@invalid.address answered:
>
> Actually Solaris ping accepts a timeout argument.
>
> % ping <hostname> <seconds>
>
> Since the default timeout is 20 seconds, I usually set it to '1' when
> testing, or my scripts can hang for a long time waiting for ping to
> timeout.
>
> I'm not sure about Lynux pings. Do they also accept a timeout argument?


-w deadline
Specify a timeout, in seconds, before ping exits regardless of
how many packets have been sent or received. In this case ping
does not stop after count packet are sent, it waits either for
deadline expire or until count probes are answered or for some
error notification from network.


--
Chris F.A. Johnson http://cfaj.freeshell.org/shell
========================================
===========================
My code (if any) in this post is copyright 2004, Chris F.A. Johnson
and may be copied under the terms of the GNU General Public License
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com