我有一个php页面,它在本地nginx服务器上的本地uri上运行。它的名称如下:http://example.dev/index.php?v=var
是否可以从Bash脚本内部调用这个php页面,使其像我在Firefox中键入uri那样运行?
我尝试在cli:中直接访问脚本
php /home/public_html/example.dev/index.php
但它没有起作用(看起来在fastCGI和php-CLI下运行的php的工作方式有所不同)。
有什么想法吗?
尝试GNU Wget
wget http://example.dev/index.php?v=var
或cURL
curl http://example.dev/index.php?v=var
像浏览器一样运行它。
注意:但这无论如何都不是CLI。
php -f <path-to-file>
php可以输出你告诉它的任何内容。它不必是HTML。
您可以使用bash脚本来调用URI页面,方法是使用类似curl
:的程序对其进行蚀刻
curl -s 'http://example.dev/index.php?v=var' > /dev/null
…或者你可以多动手,使用nc
:
echo 'GET /index.php?var' | nc example.dev 80