Re: Bash scripting help...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 8/7/06, list user <xktnniuymlla@xxxxxxxxxxxxxx> wrote:
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
>

This worked at the command line when I tested it:

$ ip=$(/sbin/arping -f -I eth0 10.255.255.1 | grep Unicast | awk
'{print $5}' | sed 's/\[/ /' | sed 's/\]/ /');echo $ip

So in a script remove the last command ";echo $ip" (and the bash $
prompt at the beginning is just that, a prompt) and you are in
business.

Jacques B.

--
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux