How do you run a command from PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
irishmike2004
Forum Contributor
Posts: 119
Joined: Mon Nov 15, 2004 3:54 pm
Location: Lawrence, Kansas

How do you run a command from PHP

Post by irishmike2004 »

Hello:

How do you run a UNIX command (like CURL) from PHP? and can the result be put into a variable? Specifically I am wanting to get local weather data from weather.com and put the result into my page.

Thanks,
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

How do you read the documentation?

http://www.php.net/curl
http://www.php.net/exec
irishmike2004
Forum Contributor
Posts: 119
Joined: Mon Nov 15, 2004 3:54 pm
Location: Lawrence, Kansas

Post by irishmike2004 »

yes but should you use exec() or shell_exec() if you just want to run it like a command line run? I was reading about exec and shell exec before I asked. The curl entry you mention looks complex.... I will post the actual command I am needing to run and perhaps then someone can tell me how to set it up. Additionally my PHP was compiled for Mac by a third party... Entrophy... I am not sure if he compiled support for Curl directly in or not.
irishmike2004
Forum Contributor
Posts: 119
Joined: Mon Nov 15, 2004 3:54 pm
Location: Lawrence, Kansas

Post by irishmike2004 »

this one is solved. Thanks, documentation was all I needed after all, was not forming curl command properly
Post Reply