daiaji
1
Hi,
Can't I use the arp
command in the shell script?
Should I use cat /proc/net/arp
instead of the arp
command?
root@OpenWrt:~# arp -a
IP address HW type Flags HW address Mask Device
192.168.1.104 0x1 0x6 * * br-lan
192.168.1.117 0x1 0x2 * * br-lan
192.168.1.133 0x1 0x0 * * br-lan
192.168.1.152 0x1 0x2 * * br-lan
192.168.1.162 0x1 0x0 * * br-lan
192.168.1.187 0x1 0x2 * * br-lan
192.168.1.218 0x1 0x2 * * br-lan
root@OpenWrt:~# cat ./test.sh
#!/bin/sh
arp -a
root@OpenWrt:~# ./test.sh
./test.sh: line 2: arp: not found
Can't I use the ARP command in the shell script?
hnyman
2
Seems to be something special with "arp", as which does not find it although the command works:
root@router1:~# arp
IP address HW type Flags HW address Mask Device
192.168.1.170 0x1 0x0 7c:46:85:..:..:.. * br-lan
...
root@router1:~# which arp
root@router1:~#
Somehow deeply built-in into busybox?
same way as "cd" ?
daiaji
3
root@OpenWrt:~# cat ./test.sh
#!/bin/sh
cd /
root@OpenWrt:~# ./test.sh
root@OpenWrt:~# cd /
root@OpenWrt:~# ./test.sh
./test.sh: line 2: arp: not found
root@OpenWrt:~# cat ./test.sh
#!/bin/sh
arp
root@OpenWrt:~# which arp
root@OpenWrt:~#
It seems that only arp has failed.
I built the openwrt image with the default configuration.
mbo2o
4
Could you use ip as an alternative
ip -4 neigh
or
ip neigh
1 Like
sammo
5
or even
cat /proc/net/arp
3 Likes
that's because on the default openwrt installation it's just a (b(a)sh) function:
If you want to use the function in a script, you could include / source /etc/profile... But yeah, it's not the full fledged arp utility.
3 Likes
hnyman
7
nice catch 
...or you can just define the same function in your own script. Basically just use
cat /proc/net/arp