f



How can I run php scripts from a shell script?

Newbie about this stuff.

I want to run some php scripts from a shell script(bash?)

the php script i want to run is this:
test.php

and it's path is this:
home/virtual/blahblah.com/home/abc/mainwebsite_html/bluhbluh/dbtest/

1. How would I creat the shell script?
2. How would I execute it?

I have already tried ot figure it out with no success.

I have php 4.2.2

Thanks

0
john9373 (6)
6/18/2005 8:27:22 PM
comp.lang.php 32646 articles. 0 followers. Post Follow

2 Replies
817 Views

Similar Articles

[PageSpeed] 50

john@munsey.net spilled the following:

> Newbie about this stuff.
> 
> I want to run some php scripts from a shell script(bash?)
> 
> the php script i want to run is this:
> test.php
> 
> and it's path is this:
> home/virtual/blahblah.com/home/abc/mainwebsite_html/bluhbluh/dbtest/
> 
> 1. How would I creat the shell script?
> 2. How would I execute it?
> 
> I have already tried ot figure it out with no success.
> 
> I have php 4.2.2

PHP can be compiled as a standalone binary or as a module for various
webservers. The former can also be used in conjunction with a webserver.
Life's a lot simpler if you have the standalone binary. I use SuSE mostly -
it's mod_php rpm includes both the module and standalone interpreter. If
you have got it on your machine it'll probably be called 'php' and is
likely to be in /usr/bin or /usr/local/bin. First thing to try would be
`which php` - then try looking in the directories for something named *php*

Then it's just a matter of running the interpreter with the script as the
first argument. e.g.

php /home/virtual/blahblah.com/home/abc/mainwebsite_html/bluhbluh/dbtest/test.php

although you may not want extraneous html in your output so....

php -q test.php


Just in case you can't find it, and can't install your own, you can fetch a
web page from the comand line using a variety of tools - most boxes will
have wget and/or curl.

HTH

C.
0
6/18/2005 9:00:24 PM
you can also set the script up like a normal shell script in the form
of...

-- start file --
#!/usr/local/bin/php -q
<?

/* php code here */

?>
--  end file --

the path to php can be take the form of

/usr/local/bin/php
/usr/bin/env php
/usr/bin/which php

etc.
they should all work out fine.

Good luck!

0
kiizaa (3)
6/19/2005 5:22:59 AM
Reply:

Similar Artilces:

run php on a script, from a script
Hi I would like to know if the following is possible and how to do it: 1) I have a "template" .php file on my server, say template.php. It contains some PHP instructions and some HTML 2) I also have a script, script.php 3) When script.php runs, I want it to run php on template.php, and write the resulting html output to a file. I need to say something like: <?php runphp ( 'template.php', 'htmloutput.html' ); ?> and obtain a file, htmloutput.html, with the result of php having run template.php (hope I'm being clear). The problem is, of course, that the runphp function doesn't exist so what is the way to do it? Thanks Fred "Fred Paris" <nono@nono.invalid> wrote in message news:mr5ku1dpuaiukdi9j85t8b002v5lepn8qm@4ax.com... > Hi > > I would like to know if the following is possible and how to do it: > > 1) > I have a "template" .php file on my server, say template.php. > It contains some PHP instructions and some HTML > > 2) > I also have a script, script.php > > 3) > When script.php runs, I want it to run php on template.php, and write > the resulting html output to a file. > > I need to say something like: > > <?php > > runphp ( 'template.php', 'htmloutput.html' ); > > ?> > > and obtain a file, htmloutput.html, with the result of php having run > template.php (hope I'm being clear). > > The...

PHP CGI script to PHP CLI script
This is my problem: I'm using PEAR package Spreadsheet_Excel_Writer to generate Excel files. Everything works fine on my test server and several production servers. But on one production server, generated Excel won't open (and data is actually in it). I can't figure out what's causing the problem (only difference is PHP version 5.1.6 vs 5.2, other required PEAR packages are identical), but I did notice during my investigation that Excel file generates and opens without problem if I execute script from command line (I use dummy PHP script with basic things needed to m...

Will Old PHP scripts Run on New PHP?
Does old PHP scripts forwards compatible with newer PHP release? > Does old PHP scripts forwards compatible with newer PHP release? that really depends on many things for example the set up of php, which functions are used etc Deal Finder <hosting@us.us> wrote or quoted: > Does old PHP scripts forwards compatible with newer PHP release? Not in general. My experience has been that changing PHP versions often casues headaches, if it hasn't been well planned for in advance. The problems are usually easy to fix, but it can still be a lot more painful than is desirable. ...

PHP Training Institute In Delhi, Live Projects on PHP. Short Term PHP Courses, PHP Scripts, PHP Training with Live Projects.
Vserve Global offers short term PHP: Hypertext Preprocessor Training Course, which is a widely used, general-purpose scripting language that was originally designed for web development, to produce dynamic web pages. It can be embedded into HTML and generally runs on a web server, which needs to be configured to process PHP code and create web page content from it. It can be deployed on most web servers and on almost every operating system and platform free of charge.PHP is installed on over 20 million websites and 1 million web servers. TOPICS:- >> Core PHP Language >> HTML, Cascad...

a PHP script works fine when called from the browser but not as a shell script
I've got a script called makeRss.php. It works fine if I try to open it with my browser. It makes an RSS feed for every page on my site. You can see it working here: http://www.autostratus.com/index.php?whatPage=makeRss It does just what I want it to do. However, I need for this script to get called every 15 minutes. So I set it up as a cron job. And cron doesn't like calling this thing. Cron is nice enough to send me an email with an error message. Every 15 minutes I get this: /home/httpd/vhosts/autostratus.com/httpdocs/makeRss.php: line 1: ?php: No such file or directory /home/httpd/vhosts/autostratus.com/httpdocs/makeRss.php: line 2: syntax error near unexpected token `"tagIndexLibrary.php"' /home/httpd/vhosts/autostratus.com/httpdocs/makeRss.php: line 2: `include_once("tagIndexLibrary.php"); Why would cron have a problem if the script works fine from the web browser? On 21 Dec 2005 09:06:53 -0800, "lawrence k" <lkrubner@geocities.com> wrote: >I've got a script called makeRss.php. It works fine if I try to open it >with my browser. It makes an RSS feed for every page on my site. You >can see it working here: > >http://www.autostratus.com/index.php?whatPage=makeRss > >It does just what I want it to do. > >However, I need for this script to get called every 15 minutes. So I >set it up as a cron job. And cron doesn't like calling this thing. Cron >is nice enough to send me an ema...

run a script from php..
Hi, I would like to run a custom script on a linux box via a button on a php page (php webpage hosted on the same linux box). Is this possible? If so , can you give me a pointer in the right direction? thanks James James, Do you mean run a custom script inside the browser's environment as the browser's user rather than the web server's environment as the web server's user? Or... Do you mean click a button in the browser window, but don't post that page to the web server, but have the web server run a script anyway? If it is the second one, you can do something ...

shell script + php
I'm writing a shell script and inside of it I have variable that I want to pass to php, but for some reason it isn't working... can someone help me? here is example #!/bin/sh i=127.0.0.1 php -r 'geoip_country_name_by_name($i);' echo $? php part works in shell if i use actual value from variable and not variable itself alexus escribi�: > I'm writing a shell script and inside of it I have variable that I > want to pass to php, but for some reason it isn't working... can > someone help me? here is example > > #!/bin/sh > > i=127.0.0.1 > > php -r 'geoip_country_name_by_name($i);' In bash, single quotes mean "do not parse variables". Try double quotes. Also, PHP require quotes around strings. -- -- http://alvaro.es - �lvaro G. Vicario - Burgos, Spain -- Mi sitio sobre programaci�n web: http://bits.demogracia.com -- Mi web de humor al ba�o Mar�a: http://www.demogracia.com -- =C3=81lvaro G. Vicario wrote: > alexus escribi=EF=BF=BD: > > I'm writing a shell script and inside of it I have variable that I > > want to pass to php, but for some reason it isn't working... can > > someone help me? here is example > > > > #!/bin/sh > > > > i=3D127.0.0.1 > > > > php -r 'geoip_country_name_by_name($i);' > > In bash, single quotes mean "do not parse variables". Try double quotes. > Also, PHP require quotes around strings....

why does it not get the value in perl run shell script to call include php file?
two file in the same folder fun.php 775 1.pl #! /usr/bin/perl $i = 0; $decryptCC = `echo '<?php include( "/home/webserve.ca/eselect/ eselect_test/fun.php" ); echo "CC" . dcc( "$i", "" ) . "CC"; ?>' | php -q`; print $decryptCC; 2. fun.php <? function dcc($char) { return "test"; } ?> 3. 1.sh #!/usr/bin/php -q <?php include('fun.php'); echo dcc(1); ?> run ./1.sh get test. 2. run ....

Spawning sub php scripts in a master script
Hey guys, Currently designing a web crawler of sorts to download some XML feeds and parse the data, was hoping to get it working in shared hosting environments. Because it only scans slowly and is designed to use limited resources, it shouldn't cause any problems or raise flags. The one issue I am running up against is script max execution time. Is there any way to spawn another instance of the script and close the initial one, daisy chaining execution every few minutes to stay under the limits? I'm unclear whether options like popen() a) work in shared environments and b) allow the process which spawns another to be shut down. If anyone has any expertise here I'd absolutely love some direction! Thanks. On Wed, 14 Nov 2007 20:34:27 +0000, kiretose wrote: > Hey guys, > > Currently designing a web crawler of sorts to download some XML feeds > and parse the data, was hoping to get it working in shared hosting > environments. Because it only scans slowly and is designed to use > limited resources, it shouldn't cause any problems or raise flags. The > one issue I am running up against is script max execution time. > > Is there any way to spawn another instance of the script and close the > initial one, daisy chaining execution every few minutes to stay under > the limits? I'm unclear whether options like popen() a) work in shared > environments and b) allow the process which spawns another to be shut > dow...

Calling (non-php) scripts from inside PHP
In my php page I am calling a Python cgi. The problem is that originally the Python script was being called directly and it could access the environment variables that were being set. Now since the php script is being called first it has access to the environment variables, but the Python script does nt. How can I forward the variables or call the Python script in such a way where it can access those variables? These are the type of environment variables I am talking about $_SERVER['HTTP_OBREQUESTEDURL'] In my php script (which is a web page) I was calling the Python cgi like this. $output=shell_exec("../cgi-bin/setaccess.cgi"." 2>&1"); //system call print $output; Greetings, Anthony Smith. In reply to Your message dated Wednesday, December 12, 2007, 22:30:55, > In my php page I am calling a Python cgi. The problem is that > originally the Python script was being called directly and it could > access the environment variables that were being set. Now since the > php script is being called first it has access to the environment > variables, but the Python script does nt. > How can I forward the variables or call the Python script in such a > way where it can access those variables? > These are the type of environment variables I am talking about > $_SERVER['HTTP_OBREQUESTEDURL'] > In my php script (which is a web page) I was calling the Python cgi > like this. > $output=shell_exec(".....

call perl script from within a php script
Hi There, I want to call a perl script from within a php script. I have tried system() and exec() commands but i'm never getting any output. The script works fine on the shell tho... :( What I've tried: <? echo '<pre>'; // Outputs all the result of shellcommand "ls", and returns // the last output line into $last_line. Stores the return value // of the shell command in $retval. //$last_line = system('ls -la'/*'./TSPtest.pl'*/, $retval); $last_line = exec(TSPtest.pl, $retval); echo "len: " . strlen($last_line) . &q...

what is wrong with this script and how do I get the value in a php script
what is wrong with this script and how do I get the value Rij1 and Rij2 and Rij3 and Rij4 and Rij5 and Rij6 in a php script import RPi.GPIO as GPIO GPIO.setmode(GPIO.BCM) GPIO.setup(17, GPIO.IN) GPIO.setup(18, GPIO.IN) GPIO.setup(21, GPIO.IN) GPIO.setup(22, GPIO.IN) GPIO.setup(23, GPIO.IN) GPIO.setup(24, GPIO.IN) Rij1 = 0 Rij2 = 0 Rij3 = 0 Rij4 = 0 Rij5 = 0 Rij6 = 0 while True: PRij1 = GPIO.input(17) PRij2 = GPIO.input(18) PRij3 = GPIO.input(21) PRij4 = GPIO.input(22) PRij5 = GPIO.input(23) PRij6 = GPIO.input(24) if (PRij1 == False): Rij1 = Rij1...

Script to run a script
I can capture the script that is running [get(scriptname)] into feld old script how can i re-run this script again from this information... like can I run script [calculated result [field(old script)] -- ------------------------------------------------- www.nsbtaxi.com Captain Guy s/v Island Time (352#277) AICW 845.5 386-689-5088 In article <5FBPg.13765$xQ1.7984@newsread3.news.pas.earthlink.net>, "Guy" <sailor@guym.com> wrote: > I can capture the script that is running [get(scriptname)] into feld old > script > > how can i re-run this script aga...

execute a shell script in a shell script
Please help. I have been stumbled on this issue, please see below. I am unable to execute a shell script in a shell script. I need to use perl script but not others and have tried eval, -exec and other on perl script but failed. system"cleartool setview -exec \"cleartool describe -fmt 'On %Sd modified %En and comment:\n %c\n\n' /myproject/vob/myprogram.C\" my_lag "; tks. On Dec 3, 8:30 am, moongeegee <moongee...@gmail.com> wrote: > Please help. > I have been stumbled on this issue, please see below. I am unable to > execute a shell script in a shel...

running php scripts from a CD
is there a way to run PHP scripted pages from a CD on a machine that doesnt have internet access ?? can some sort of fake server be setup ?? chris The only thing I'm aware of: http://www.dwebpro.com/ Cheers, Daniel http://www.danhendricks.com i did something like that once, but it's a while ago. I used some installer-creator-program-thingy to create an install.exe that whould install apache and mysql service (in the background =D) and php, insert the content to the database and copy the php files to htdocs dir, and than created some shortcuts. This was on a windows machi...

Run PHP-Script in Background
I am using php 5.0.4 under IIS 6 under Windows Server 2003 and want to run a php-script as a separate process. This schript dies not have any output. I tried several variants without success: exec("c/php5/php.exe path/to/script parameters &") will run the schript but will wait until the schript finished processing. exec("c/php5/php.exe path/to/script parameters > null &") gives me the error message "The specified CGI application exceeded the allowed time for processing. The server has deleted the process." Dealing with other variants of php cli procesors like php-win.exe gave the same result. Also trying to use the start command did not help. My head is burned out, what else could run my script under this environment? Thanks for any ideas. Thomas Do you need your script to run constantly? Or should it run only once after x-many days/hours/minutes? I had a similar task to do in a W2K environment. I wrote a master PHP script with set timings on when to run each secondary script bazed on time of day. Then I just put that mster script in the Windows scheduler so it runs every hour... That did my job but I don't know if that's what you are looking for. > Do you need your script to run constantly? Or should it run only once It should run only once, and I need to send a parameter with. It's actually a script which would run too long to wait on with the browser, so it would run into the timeout limits. So I could ...

Run PHP script from bash
I'm trying to run a PHP file as a shell script (with the regular /usr/bin/php interpreter). It looks like this: #!/usr/bin/php -q -d html_errors=0 <? echo "This is a test\n"; ?> This is the result of the execution: $ ./cibervivienda.php Error in argument 1, char 3: option not found Error in argument 1, char 4: option not found - Error in argument 1, char 3: option not found I can solve it removing the "-d html_errors=0" part but then I get HTML-formated errors. I can't find the logic because the option is definitively accepted if I type it myself: $ /usr/...

when does a PHP script stop running?
Suppose I create dynamic web pages with 3 functions (which call other functions to make everything happen, but these 3 you might think of as being the top layer): registerSessions(); sendHtmlToBrowsers(); incrementPageViews(); Is there any chance that incrementPageViews() will be executed? Or, to turn that question around, does anyone know a reason why it wouldn't? Does PHP stop executing when the last of the HTML is sent to the webbrowser (I've heard both yes and no on this newsgroup and I'm hoping for a definitive answer). Okay, now lets suppose that I do this (this is closer...

Why is shared host php GID and UID the same in my PHP Script?
I ran this: $processUser = posix_getpwuid(posix_geteuid()); echo("<pre>"); print_r($processUser); echo("</pre>"); I got this result: Array ( [name] => aremssp [passwd] => x [uid] => 2244 [gid] => 2244 [gecos] => [dir] => /home/aremssp [shell] => /usr/local/cpanel/bin/noshell ) Why are the GID and UID the same? SMHealthNick wrote: > I ran this: > $processUser = posix_getpwuid(posix_geteuid()); > echo("<pre>"); print_r($processUser); echo("</pre>"); ...

Changing a script so it can run alongside another script
The code below runs two scripts.... myfile.js and the add to favorites script. These work fine when on the page separately... but together only the myfile.js script works. I want to make both work... how is this done? I would like to have the add to favourites script in a file as myfile.js is..but am unsure of how to do this, Thanks for any help!! .. .. .. .. <script language="JavaScript" src="myfile.js"> </head> <script language="JavaScript1.2"> /* Add-to-favorites Script */ //configure the two variables below to match yo...

Script Script
Ever want to try a little script to see if it will work but don't want to go through the hassle of creating a file with #!/bin/bash at the top and making it executable and running it as ./script-name and then deleting it or moving it? You can use the fc command in bash, but it runs in the current shell, which can cause real problems, and once you've done it, if it is more than one line, or you do anything else in between at the prompt, it's gone. fc also echos the script, which is really ugly and confusing. So I wrote this little script which has been tremendously u...

Running PL/SQL scripts from PHP
Hi. Is there a way to execute PL/SQL scripts from PHP? I have PL/SQL scripts that utilizes the DBMS_xxx packages. Is it possible to shell out a command that will run the PL/SQL? -DN In news:bup1l1$t59$1@woodrow.ucdavis.edu, Dung Nguyen <dung@ucdavis.edu> typed: > Hi. > > Is there a way to execute PL/SQL scripts from PHP? I have PL/SQL > scripts that utilizes the DBMS_xxx packages. Is it possible to shell > out a command that will run the PL/SQL? > > -DN Yes. Use the system function. Apache must have permission to run the script. -- -linux_lad To verify that...

how to enable permissions in htaccsess for php file.php script problems
I am having problems with a ftp to http php scrip: Warning: ftp_get(): open_basedir restriction in effect. File(/ftp_login.html.600490715) is not within the allowed path(s): (/home:/tmp:/usr) in /home/jbsmedia/public_html/ftp.php on line 352. when i download files, when i upload i get Upload failed! Can't create temp file?. as far as i fuigured i set my ftp file folder cmod 777. then must have to do somethin to the htaccess file. my host is running a unix appache server. i found it has something to do with internal server error 500 and mkdir command= mkdir /var/tmp/xfers && chmod 1777 /var/tmp/xfers */ $phpftp_tmpdir="/var/tmp/xfers" can anyone help sorry type error http to ftp script ...

SCRIPT PHP
Salut tout le monde, je rencontre quelque probl�mes en PHP car je ne suis pas un pro :-( Je voudrais deux script le premier c'est une page de contact.htm dans la quelle il y a : nom, pr�nom, adresse, societe, mail, ville code postal et num tel. D�s le visiteur saisie c donn�es il une base Mysql(car je travail avec PHP/MYSQL) r�cup�re les donn�es apr�s avoir �ffectu� une verification de la validation de la forme du mail(******@***.***). Ainsi une table client est cr�er, et aussi lui donner la possibilit� de se d�sincrire. Le deuxi�me une page de parrainage, c-a-d une personne qui d�j� ins...

Web resources about - How can I run php scripts from a shell script? - comp.lang.php

Seal script - Wikipedia, the free encyclopedia
Seal script ( simplified Chinese : 篆书 ; traditional Chinese : 篆書 ; pinyin : zhuànshū ) is an ancient style of Chinese calligraphy . It evolved ...

Super Tuesday played according to script - now everything changes
Hillary Clinton can now position herself as the grown-up in the room for the general election, while Donald Trump is setting himself up for a ...

I’ve Just Read The Pilot Script To DC Comics And NBC’s New Comedy, Powerless (UPDATE)
Emily, Del, Jackie, Teddy... UPDATE: Script scans excerpts removed, at the request of Asad Kazi of Warner Bros. Entertainment Inc. So that's ...

UnitedHealth Takes on CVS, Express Scripts With Drugs Deal
UnitedHealth Group Inc.’s OptumRx unit struck an agreement to ease customers’ access to drugs through Walgreens Boots Alliance Inc.’s drugstores, ...

Trump sticks to the script in AIPAC speech
GOP front-runner gives a speech from prepared remarks for the most part, anyway

Netflix Commits $90M+ For David Ayer-Directed Will Smith-Joel Edgerton Pic ‘Bright;’ $3M+ For Max Landis ...
EXCLUSIVE : A two-week bidding battle has finally ended and Netflix has won Bright , a Max Landis scripted cop thriller with fantastical elements ...

'Game of Thrones': Jon Snow death script pages revealed - EW.com
It’s the moment that broke the hearts of fans around the world: The Night’s Watch betraying and murdering their Lord Commander (Kit Harington) ...

Script Analysis: Robert Carlock On Writing "Whiskey Tango Foxtrot"
Tina Fey's writing partner on adapting journalist Kim Barker's memoir, The Taliban Shuffle: Strange Days in Afghanistan and Pakistan . Though ...

Script For A Perfect Job Interview
Here's a script of a manager (Brittany) interviewing a job candidate (Gustavo) in a non-scripted, conversational way. Could you start interviewing ...

Change to Mail Service in Apps Script
Originally posed Google Apps Developers Blog Posted by Saurabh Gupta, Product Manager, Google Apps Script There are two ways to send email ...

Resources last updated: 3/24/2016 1:28:00 AM