通过curl从终端呼叫发送输出

时间:2015-10-12 15:28:31

标签: php curl terminal

我现在有以下命令行脚本:

df -h | curl -F stuff=test http://foo.com

哪个会向foo.com发送POST请求。在$_POST变量中,我有以下数据集:

[stuff] => test

现在我想使用test的输出更改df -h,以便我可以在$_POST变量中看到它。

我该怎么做?

2 个答案:

答案 0 :(得分:3)

您可以使用xargs

df -h | xargs -I % curl -F stuff=% http://foo.com

答案 1 :(得分:2)

你有什么尝试?这可能会实现目标。试试看,让我知道。

curl -F "stuff=`df -h`" http://foo.com