LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   can i run .php trom terminal (https://www.linuxquestions.org/questions/linux-software-2/can-i-run-php-trom-terminal-435783/)

samnjugu 04-16-2006 07:36 PM

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:newbie:

haymaker2000 04-16-2006 08:11 PM

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.

samnjugu 04-18-2006 05:26 PM

ityped the command in yum and it tells me no match for argument: php5-cli
am runing fedora 4 with php5.

spooon 04-18-2006 05:56 PM

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.

mrjamin 04-18-2006 07:09 PM

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.

samnjugu 04-19-2006 07:27 AM

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.

samnjugu 04-20-2006 07:54 AM

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


All times are GMT -5. The time now is 11:14 PM.