遇到的现象
命令行中使用正常,如图
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/2b4fb37cdcb30b3d342ab7aa06f56744.png)
shell中使用报错(line 3: arp: not found)
#!/bin/sh
arp
输出结果:
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/ef49c47858ea853754393b5db657e61c.png)
解决
经过一段时间的研究和查询,最终发现在 openwrt中 arp 确实不是一个命令,而是
cat /proc/net/arp,之所以可以直接使用,是因为/etc/profile 中增加了如下代码:
[ -x /usr/bin/arp -o -x /sbin/arp ] || arp() { cat /proc/net/arp; }
希望遇到此问题的小伙伴都可以通过本篇文章解决困扰,感谢观阅!!!