简体   繁体   English

使用PHP脚本从Mac OS-X上的shell脚本调用Web URL

[英]Call web URL with PHP script from a shell script on Mac OS-X

I have a server with a PHP script that pulls data from a source and populates a database. 我有一个带有PHP脚本的服务器,它从源中提取数据并填充数据库。 I need to call this PHP script repeatedly, each time with a different parameter. 我需要重复调​​用这个PHP脚本,每次使用不同的参数。

I need to create a shell script on a Mac (which reads in a text file with the list of parameters - that part is not a problem) and for each parameter, runs the PHP script/URL in a web browser. 我需要在Mac上创建一个shell脚本(使用参数列表读入文本文件 - 该部分不是问题),并且对于每个参数,在Web浏览器中运行PHP脚本/ URL。

The PHP is on a remote server, so I need to load a web browser instance (safari or firefox) and instruct it to load the URL (ie. something like http:/myserver.com/scriptname.php?param1). PHP位于远程服务器上,因此我需要加载Web浏览器实例(safari或firefox)并指示它加载URL(例如http:/myserver.com/scriptname.php?param1)。 Then I need to wait for it to complete and trigger the same URL with the next parameter. 然后我需要等待它完成并使用下一个参数触发相同的URL。

I don't know the incantation to launch the web browser with a URL (I am a former Windows dev not a Mac OS-X pro, yet). 我不知道使用URL启动Web浏览器的咒语(我以前的Windows开发人员不是Mac OS-X专业版)。 I also don't think there is a way to detect when the script completes - but I don't want to end up with 100 instances of the browser running simultaneously. 我也认为没有办法检测脚本何时完成 - 但我不想最终同时运行100个浏览器实例。

Any help would be greatly appreciated! 任何帮助将不胜感激!

If you just need it to hit a php page on a remote server, don't use a browser. 如果您只是需要它来访问远程服务器上的php页面,请不要使用浏览器。 Use curl, or some equivalent. 使用卷曲或一些等效物。

curl http:/myserver.com/scriptname.php?param1

open -a Safari http://stackoverflow.com

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM