LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-16-2006, 07:36 PM   #1
samnjugu
Member
 
Registered: Apr 2006
Location: Atlanta
Distribution: Centos, knoppix, Fedora, Mepis, Zenwalk, Mint
Posts: 142

Rep: Reputation: 16
can i run .php trom terminal


i want to know if its posibble to run a php script from terminal or i need to have my browser up
 
Old 04-16-2006, 08:11 PM   #2
haymaker2000
Member
 
Registered: Jan 2006
Location: New Zealand
Distribution: Ubuntu 5.10 (Breezy), Debian 3.1 (Sarge)
Posts: 37

Rep: Reputation: 15
Yes, that is possible. just run
Code:
#php <filename>.php
If the command line interpreter is not installed, do something like (debian based distros)
Code:
#apt-cache search php command line interpreter
which should give you something like
output:
php4-cli - command-line interpreter for the php4 scripting language
php5-cli - command-line interpreter for the php5 scripting language

and install the correct package for your system with
Code:
#apt-get install php4-cli
If you don't have a debian based distro, use the corresponding commands with yum. If you do not have yum or apt-get, get it. Just google for "apt-get install" or "yum install".

Then you can do the above.
 
Old 04-18-2006, 05:26 PM   #3
samnjugu
Member
 
Registered: Apr 2006
Location: Atlanta
Distribution: Centos, knoppix, Fedora, Mepis, Zenwalk, Mint
Posts: 142

Original Poster
Rep: Reputation: 16
ityped the command in yum and it tells me no match for argument: php5-cli
am runing fedora 4 with php5.
 
Old 04-18-2006, 05:56 PM   #4
spooon
Senior Member
 
Registered: Aug 2005
Posts: 1,755

Rep: Reputation: 51
The regular "php" package comes with the command-line interpreter, so if you have PHP installed then you can run php on the command line.

Last edited by spooon; 04-18-2006 at 05:58 PM.
 
Old 04-18-2006, 07:09 PM   #5
mrjamin
LQ Newbie
 
Registered: Sep 2003
Location: UK
Distribution: FC7
Posts: 27

Rep: Reputation: 15
Code:
# php -f php-file.php
You can also create php scripts designed to run in the terminal like so:

1) Fire up a text editor and create your file, eg:

PHP Code:
#!/usr/bin/php
// ^^ that line tells the command line that the file should be parsed by the php CLI interpreter
echo "Hello terminal\n"
2) Give the script execute permissions:

Code:
# chmod +x script.php
3) Execute your script:

Code:
# ./script.php
Hello terminal
This is all assuming you have the CLI version of PHP. FC installs this by default.
 
Old 04-19-2006, 07:27 AM   #6
samnjugu
Member
 
Registered: Apr 2006
Location: Atlanta
Distribution: Centos, knoppix, Fedora, Mepis, Zenwalk, Mint
Posts: 142

Original Poster
Rep: Reputation: 16
the install command am trying to run wont run from command as the installer reports it cant find folders already in it's directory.Thank you for your help but it seems i will have to try and run it from browser as that is what comes with instructions on installing. by the way the app am trying to install is coppermine.
 
Old 04-20-2006, 07:54 AM   #7
samnjugu
Member
 
Registered: Apr 2006
Location: Atlanta
Distribution: Centos, knoppix, Fedora, Mepis, Zenwalk, Mint
Posts: 142

Original Poster
Rep: Reputation: 16
solved here's the thread to it thanks everyone for your contributions
http://www.linuxquestions.org/questi...d.php?t=436080
 
  


Reply

Tags
command, executable, interpreter, line, linux, php, script


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Apache 2, PHP 5, SuSE 9.2 - cannot run php files dickohead Linux - Networking 6 06-28-2006 10:25 AM
Is there a terminal command that I can run that will........... ludwig W Linux - Networking 20 11-28-2005 03:59 PM
How to run MP3 file thru Terminal in K.D.E or Terminal itz2000 Linux - Newbie 5 08-04-2005 09:49 PM
How do I run a browser in a terminal? Ultwe Linux - Newbie 5 06-30-2005 04:55 PM
help getting pptp-php-gtk.php to run as root mrtwice Linux - Software 0 11-21-2003 12:49 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:34 PM.

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