Forum Moderators: coopster

Message Too Old, No Replies

PHP Command Line

What do you use it for?

         

Nick_W

8:21 am on Aug 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I didn't even know you could use PHP from the command line untill recently.

So, what would one use it for?

Nick

MonkeeSage

8:32 am on Aug 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Nick_W:

I'm going to get murdillated for even suggesting such a horror, especially considering the forum we're in, but I imagine mostly the same stuff I use JavaScript for locally. ;)

I.e., Parsing datasets, systematically duplicating datasets with incremented elements, finding differences between datasets, transforming datasets by a rule, maths, &c.

I would think the only real difference would be the datasource (DBs in PHP; iframe / textarea (or files, using Mozilla w/ jslib) in JS).

Jordan

grey259

2:26 pm on Aug 13, 2003 (gmt 0)

10+ Year Member



I use it to call scripts from cron.

Particularly, my billing system uses it to generate invoices nightly for a subscription based service.

Other uses could be interaction with other scripting languages. Perhaps a call to a php groupware program whenever a user logs in or out of a system shell account. Or something similar anyway..

[edited by: grey259 at 2:35 pm (utc) on Aug. 13, 2003]

dmorison

2:35 pm on Aug 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I use it to call scripts from cron

I'll second that.

Many people take the easy way out and have cron do a wget on a [127.0.0.1...] introducing loads of security holes into their maintenance scripts. You really should use the PHP binary instead!

shrirch

2:56 pm on Aug 13, 2003 (gmt 0)

10+ Year Member



I use it via cron to update Amazon data.

dingman

3:45 pm on Aug 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Most of the stuff I used to write little Perl scripts for, I now do in PHP. I got started with such things because I have a web community system that accepts messages both through the web site and by e-mail, and I want the procmail filter that processes incoming messages to share code with the web page, which requires that they be written in the same language.

Since then, I've found that I like the increased readability of my PHP scripts, so I use them instead of Perl a lot. Your mileage may vary. For me, Perl feels like a write-only language and PHP doesn't, but there are plenty of people who disagree.

driesie

4:18 pm on Aug 13, 2003 (gmt 0)

10+ Year Member



I use it for maintance scripts all the time.
DB backups, file backups, importing xml data stream in my DB, creating a cache ...

Some of it through cron, some of it manually.

As mentioned by MonkeeSage you could do a lot of that locally by using JScript (using Windows Scripting Host), but off course it would only work in WIN32 machines.

I like it because it's a scripting language I know ;)

jatar_k

4:28 pm on Aug 13, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I have some maintenance scripts, specific debug scripts, crons and whatever else I can think up. ;)

panic

6:06 pm on Aug 13, 2003 (gmt 0)

10+ Year Member



I use command line PHP for TONS of stuff.

For one, I use it to update a perl script that I've got in one of my million cgi-bin's.

I also use it to break up hefty text files into small, managable ones (minus all the junk from the original text file).

I also use it on my computer at home for local testing when I don't feel like uploading each PHP file to my webserver. (Windows absolutely doesn't do Apache/PHP any justice).

I also use it for a million and one other things, but those mentioned above are the ones used most often.

-panic