Re: Bash scripting help...
- From: list user <xktnniuymlla@xxxxxxxxxxxxxx>
- Date: Mon, 07 Aug 2006 14:40:39 -0700
Marko Vojinovic wrote:
I am writing a bash script to discover a MAC address of a remote host based on it's IP. Found that arping might be useful (is there a better method?), so I get
# arping -f -I eth0 $ipnumber
ARPING 10.0.0.3 from 10.0.0.1 eth0
Unicast reply from 10.0.0.3 [00:0C:29:C8:DE:E2] 1.040ms
Sent 1 probes (1 broadcast(s))
Received 1 response(s)
but the problem is that I just need to set the variable, say macaddr, to the above value, hopefully lowercase, without the [ and ]. Next obvious thing was:
# arping -f -I eth0 $ipnumber | grep Unicast
Unicast reply from 10.0.0.3 [00:0C:29:C8:DE:E2] 1.040ms
but I am over my head in extracting just the number. I guess awk is the tool, but the man page is not very illustrative and I do not have time/patience to learn to program in 'awk language' in order to do this thing. And C would probably be an overkill... :-)
Or this may work... (with the correct IP :/)
arping -f -I eth0 10.0.0.3 |\
grep Unicast |\
sed -e 's/.*\[\(..:..:..:..:..:..\)\].*/\1/'
--
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
- Follow-Ups:
- Re: Bash scripting help...
- From: Jacques B.
- Re: Bash scripting help...
- References:
- Bash scripting help...
- From: Marko Vojinovic
- Bash scripting help...
- Prev by Date: Re: Bash scripting help...
- Next by Date: RE: ssh or telnet: different pathspec
- Previous by thread: Re: Bash scripting help...
- Next by thread: Re: Bash scripting help...
- Index(es):
Relevant Pages
|