LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 11-28-2006, 12:42 AM   #1
kev000
Member
 
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?

thanks

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, 01:10 AM   #2
jiml8
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, 01:12 AM   #3
twilli227
Member
 
Registered: May 2003
Location: S.W. Ohio
Distribution: Ubuntu, OS X
Posts: 760

Rep: Reputation: 30
Maybe try this:

http://72.14.203.104/linux?q=cache:n...s&ct=clnk&cd=2

Or better yet, check out the pdf on the second result, it shows better:

http://www.google.com/linux?hl=en&lr...e+&btnG=Search
 
Old 11-28-2006, 04:00 PM   #4
Cynagen
LQ Newbie
 
Registered: Jul 2004
Distribution: Slackware 11
Posts: 15

Rep: Reputation: 0
Quote:
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.

Example:

#!/usr/bin/php

<?php
//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, 04:16 PM   #5
fw12
Member
 
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 "http://www.yourdomainname.com/yourphpscript.php" > /dev/null 2>&1

Or you can run it from the commandline.
 
  


Reply


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 08:19 PM
Command Line PHP in Slack 10 Trano Slackware 4 02-12-2005 06:16 PM
php command line scripts naflan Programming 5 11-09-2004 09:02 AM
Command Line PHP on Mandrake Dilireus Linux - Software 2 08-04-2004 06:46 PM
php from command line odious1 Linux - Software 4 05-03-2004 01:31 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:35 AM.

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