使用Arp-Scan的Sudo Cron作业给出空输出

梅迪·内伦(Mehdi Nellen)

我编写了一个脚本hello.sh,其中包含以下内容:

#!/bin/bash

printf "$( arp-scan --interface=eth0 --localnet )\n"
printf "test\n"

将其设为可执行(chmod o+x)并运行(./hello.sh >> file.txt)后,我得到了正确的输出file.txt(这是arp扫描结果和字符串“ test”)。但是在将以下行添加到后crontab -e

*/1 * * * *  /path/to/hello.sh >> /path/to/file.txt

我得到以下输出:


测试

测试

测试

如您所见,arp-scan零件返回了一个空字符串我如何使arpscan与cron一起使用?

附加信息:以sudo(sudo -i登录后,一切完成arp-scan需要须藤。我正在Fedora 20上运行它。

八比特通

cron 在最小的环境和减少的路径下运行。

在设计用来执行的脚本中,最安全的做法是cron确保所有命令都具有提供的完整路径,或者脚本设置自己的PATH变量。

尝试将完整路径添加到arp-scan命令。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章