您好,每当我运行我的外壳脚本时,结果是"curl:(6)无法解析主机'(temp=35.4&lux=7&hum=23.8)‘,然后它打印出我的php文件中的代码,该文件执行恢复数据并将其放入文本文件中。有人知道这是什么问题吗?
while true;
do sleep 2
/home/GPIO/led 1
temp="$(/home/Temp/getTemp)"
lux="$(/home/Light/getLux)"
hum="$(/home/Humid/getHumid)"
/usr/bin/curl "("'temp'=$tmp'&''lux'=$lux'&''hum'=$hum")" http://192.168.4.3/api.php
在我的api.php
<?php
$recivedpostdata=file_get_contents('php://input');
$datafile = 'data.txt';
file_put_contents($datafile,$recivedpostdata);
echo $recivedpostdata;
?>
发布于 2015-07-28 14:35:03
试试curl --data "temp=...&lux=..." http://192.168.4.3/api.php
不确定您想要实现什么,但是如果您想要POST
temp等作为参数,应该可以这样做。看看https://superuser.com/questions/149329/what-is-the-curl-command-line-syntax-to-do-a-post-request吧。
https://stackoverflow.com/questions/31667048
复制相似问题