我有这个 .sh
单行脚本:
curl http://example.com/script.php
服务器上的 script.php
如下所示:
echo "hello"
如何修改 .sh
脚本来捕获 script.php
的输出?
最佳答案
How can I modify the .sh script to catch the output of script.php?
您可以像这样在变量中捕获它:
MY_VAR=$(curl -s http://example.com/script.php)
使用 -s
来防止进度显示在标准输出中。从这里您可以使用 $MY_VAR
来控制输出。
关于php - 将 PHP 脚本的响应打印到客户端,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37060469/