473,770 Members | 2,160 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_htm l/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

Jul 17 '05 #1
2 2092
jo**@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_htm l/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_htm l/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.
Jul 17 '05 #2
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!

Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3373
by: eichin | last post by:
One of my recent projects has involved taking an accretion of sh and perl scripts and "doing them right" - making them modular, improving the error reporting, making it easier to add even more features to them. "Of course," I'm redoing them in python - much of the cut&paste reuse has become common functions, which then get made more robust and have a common style and are callable from other (python) tools directly, instead of having to...
9
3657
by: Jeff Wagner | last post by:
I have a project of converting numerous DOS cmd shell scripts to Python. Is there a tutorial to getting started? Thanks, Jeff
2
12750
by: RJ | last post by:
We currently send product releases to our customers, and often have to include scripts that need to be ran on the Oracle databases (also do it for SqlServer customers, but we use a different set of scripts for that). Some of the Sql scripts can be quite long, and so we break them out to their own script files and call them all from one main ..sql file, using sqlplus to execute it all. The admin would run the file like:
8
2029
by: Jan Danielsson | last post by:
Hello all, How do I make a python script actually a _python_ in unix:ish environments? I know about adding: #!/bin/sh ..as the first row in a shell script, but when I installed python on a NetBSD system, I didn't get a "python" executable; only a "python2.4"
1
1828
by: sandercaerteling | last post by:
Hi There! I created a few python scripts and everything is working fine. But to make it easier to run the procedure i want to couple these scripts in one big script. Is there a possibility to do this, can I for example make a script dat 'calls' the other script in the right order? Many thanks! Sander
0
1713
by: paulhjwu | last post by:
Hi, I have problems running a couple of shell scripts from PHP. I found a similar posting, so I posted my question to the original author. But unfortunately the original author is not at the address anymore. Anyone can help with the problems highlghted below?
24
2849
by: Mark | last post by:
Hi, I'm new to python and looking for a better idiom to use for the manner I have been organising my python scripts. I've googled all over the place about this but found absolutely nothing. I'm a linux/unix command line guy quite experienced in shell scripts etc. I have a heap of command line utility scripts which I run directly. What is the best way to create python command line scripts but exploit the (loadonly) speed-up benefit of...
1
9101
by: sainathr | last post by:
Hi, I would like to run shell scripts with respect to the time mentioned in postgres data base tables. Postgres database should trigger the shell script for the time mentioned in the table. To make it more clear, i will add an entry like as below in postgres database table file_id script_run_time crd_extract.sh 13:00 Now as part of automation process postgres database should trigger the script...
9
15533
by: Catherine Moroney | last post by:
I have one script (Match1) that calls a Fortran executable as a sub-process, and I want to write another script (Match4) that spawns off several instances of Match1 in parallel and then waits until they all finish running. The only way I can think of doing this is to call it as a sub-process, rather than directly. I'm able to get Match1 working correctly in isolation, using the subprocess.Popen command, but calling an instance of Match1...
0
9618
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10260
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10038
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7456
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6712
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2850
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.