Linux Today: Linux News On Internet Time.
Search Linux Today
Linux News Sections:  Developer -  High Performance -  Infrastructure -  IT Management -  Security -  Storage -
Linux Today Navigation
LT Home
Contribute
Contribute
Link to Us
Linux Jobs


More on LinuxToday


Using PHP directly from the command line on Linux and UNIX

May 20, 2009, 06:03 (0 Talkback[s])
(Other stories by Thomas Myer)

[ Thanks to An Anonymous Reader for this link. ]

"At some point, though, you want to do more, or you're forced to do more. By that, I mean you have to work directly with the file system of the server PHP is running on. You end up needing to work with files on the file system, understand what processes are running, or perform some other task.

"At first, you're content using commands like file() in PHP to open files. At some point, though, the only way to get something done is to be able to run shell commands on the server and get back some type of output. For example, you might need to know how many files live in a certain directory. Or you may need to know how many lines have been written to a group of log files. Or you may need to operate on those files to copy them to another directory or use rsync to transport them to another location.

"In "Command-line PHP? Yes, you can!," Roger McCoy shows how to use PHP directly from the command line -- no Web browser needed. In this article, I approach the subject from the other point of view, showing you how to integrate closely with underlying shell commands and folding any return values into your interfaces and processes."

Complete Story

Related Stories: