php - 使用wget向php发送数据

标签 php linux unix wget uptime

我正在尝试访问 PHP url 并使用 cron 作业和 wget 发布有关我的 Linux 机器的一些信息。

*/30 * * * * wget -O /dev/null http://ping.xxx.com/xxx/up.php?mac=`ifconfig eth1 | awk '/HWaddr/ { print $5 }`\&uptime=`uptime`\&ip=`ifconfig eth1 | awk '/inet addr:/ {sub(/addr:/, "", $2); print $2 }`;

在 php 方面,我尝试获取请求参数,例如 mac、正常运行时间和 ip,但我只能记录 mac。我认为的原因是因为 uptime 命令有 23:42:10 up 22 min, loadaverage: 0.00, 0.01, 0.04 作为输出,这可能会破坏 wget 进程。当我运行 wget 时收到以下消息

wget: not an http or ftp url: 23:42:10

有人可以告诉我如何正确传递参数吗?

最佳答案

尝试这样:

*/30 * * * * wget -O http://ping.xxx.com/xxx/up.php?mac=`ifconfig eth1 | awk '/HWaddr/ { print $5 }`\&uptime=`uptime`\&ip=`ifconfig eth1 | awk '/inet addr:/ {sub(/addr:/, "", $2); print $2 }` /dev/null;

您将/dev/null 放在 wget 需要 url 的位置,您只需切换/dev/null 和 url

关于php - 使用wget向php发送数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21761874/

相关文章:

php - 使用动态框架调整图像大小

php - php 5.6以上在xampp中安装php ffmpeg

python - 在 Python 解释器 : Explain behavior 中运行 Python 解释器

linux - github 问题 api 和 jq 过滤器和 grep

linux - 如何根据用户标识将符号目录链接映射到不同的目录

linux - 用于排序 CSV 的 Unix 命令之间的差异

c++ - 如何修复错误 "was not declared in this scope"?

php - 在 Mediawiki 中使用小写页面标题

php - Doctrine\DBAL\Driver\PDOException SQLSTATE[HY000] [2006] MySQL 服务器已消失

linux - vim 向上或向下移动选定代码块