LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-22-2005, 03:34 PM   #1
petenyce
Member
 
Registered: Sep 2005
Posts: 39

Rep: Reputation: 15
call a php file


Im trying to call a php file in a linux bash script is this correct syntax?

#!/bin/bash
/usr/etc/script.php


???

thanks
 
Old 11-22-2005, 04:18 PM   #2
spooon
Senior Member
 
Registered: Aug 2005
Posts: 1,755

Rep: Reputation: 50
PHP files are usually not executable (unless you put a shebang on their first line and then give them executable permission); so try "php /usr/etc/script.php". Also, keep in mind that it outputs a complete HTML file including the headers.
 
Old 11-22-2005, 04:38 PM   #3
CroMagnon
Member
 
Registered: Sep 2004
Location: New Zealand
Distribution: Debian
Posts: 900

Rep: Reputation: 33
If:

the PHP script is marked executable
AND
the first line is a #! line with the path to your PHP binary.

otherwise, you'd be better off specifying the path to the PHP binary and the name of the script on the command line itself.

Code:
#!/bin/bash
PHP=/usr/local/bin/php

$PHP /usr/etc/script.php
Check the man page for any switches you might need to add (depending on the script).
 
Old 11-23-2005, 04:21 AM   #4
fouldsy
Senior Member
 
Registered: Jan 2002
Location: St Louis, MO
Distribution: Ubuntu
Posts: 1,284

Rep: Reputation: 47
You might also need to install php-cgi in order to run PHP scripts from the command line
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Call to undefined function imagettfbbox() QtCoder Programming 24 01-18-2012 01:20 PM
Call a shell script from php? jharper101 Programming 2 02-15-2005 01:51 AM
call perl cgi script from php j-ray Programming 2 01-14-2005 09:23 AM
call php scripts djgerbavore Programming 3 11-30-2004 08:17 AM
Call to undefined function: mail() in PHP pembo13 Fedora 0 07-28-2004 08:40 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:38 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration