Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 11-27-2006, 11:42 PM   #1
Registered: Oct 2006
Posts: 53

Rep: Reputation: 15
PHP on the command line?

Is there anyone who knows how I can launch a .php scripts from the command line without using a browser?


P.S. the php script simply gets a rss link from mysql, parses it, and puts it back into mysql (this is totally automatic so a web browser is useless if that makes sense).
Old 11-28-2006, 12:10 AM   #2
Senior Member
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 116Reputation: 116
php myscript.php

What happens then just depends on what the script does; could be useless. For the case you decribe, it should work OK.
Old 11-28-2006, 12:12 AM   #3
Registered: May 2003
Location: S.W. Ohio
Distribution: Ubuntu, OS X
Posts: 760

Rep: Reputation: 30
Maybe try this:

Or better yet, check out the pdf on the second result, it shows better:
Old 11-28-2006, 03:00 PM   #4
LQ Newbie
Registered: Jul 2004
Distribution: Slackware 11
Posts: 15

Rep: Reputation: 0
Originally Posted by jiml8
php myscript.php

What happens then just depends on what the script does; could be useless. For the case you decribe, it should work OK.

you can go a step further and actually make the PHP script executable... same way you do a CGI or PerL file...

Start the php script with: #!/usr/bin/php (or whatever your path to PHP is)
and make sure to leave at LEAST one blank line after it or the first line: <?php (most important) will not be parsed and the entire thing will not work.



//just a test script
echo "hello world!\n";

Save that as just plain "myscript" then "CHMOD 755 myscript", and finally "./myscript", VIOLA! You wrote your first shell php script, (I write tons of them, I don't like perl, not enough web integration.)
Old 11-28-2006, 03:16 PM   #5
Registered: Mar 2006
Distribution: Fedora core, Ubuntu
Posts: 175

Rep: Reputation: 31
What you're trying to do can be done with lynx.

If it's a repeating job, just add something like this to crontab:

30 * * * * /usr/bin/lynx -dump "" > /dev/null 2>&1

Or you can run it from the commandline.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[php] accessing command line dtra Linux - Software 1 04-26-2005 07:19 PM
Command Line PHP in Slack 10 Trano Slackware 4 02-12-2005 05:16 PM
php command line scripts naflan Programming 5 11-09-2004 08:02 AM
Command Line PHP on Mandrake Dilireus Linux - Software 2 08-04-2004 05:46 PM
php from command line odious1 Linux - Software 4 05-03-2004 12:31 AM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:31 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration