hello,
when a web request comes to my index.php, i would like index.php to execute
a php script stored in an external file and capture the external script's
output to a variable.
i am doing this because the external script can read the database and can
emit xml that i want to use. index.php (or whatever) wants to grab this xml
and pass it through an xslt.
i know that if the external php script had a function declared, and the
function returned a string value with the xml contents, then i could use
"require" or a similar construct and call the function. the question that i
am trying to answer is what to do if the external script uses echo() to
output the results? how to capture its output during request processing?
besides, i do not like spawning another process for that and piping to it.
it might not scale well. ;-)
please help.
thanks
konstantin 3 11620
Use the -q directive to suppress headers
In index.php:
$stdout_var = shell_exec(/usr/local/bin/php -q /path/to/the/php/file.php);
Make sure file.php is chmod 755 or thereof
Check the path to php (could be "sbin")
You could write $stdout_var to file or do whatever from here.
On 2/25/05 1:25 PM, in article e-*************** *****@kallback. com, "konsu"
<ko***@hotmail. com> wrote: hello,
when a web request comes to my index.php, i would like index.php to execute a php script stored in an external file and capture the external script's output to a variable.
i am doing this because the external script can read the database and can emit xml that i want to use. index.php (or whatever) wants to grab this xml and pass it through an xslt.
i know that if the external php script had a function declared, and the function returned a string value with the xml contents, then i could use "require" or a similar construct and call the function. the question that i am trying to answer is what to do if the external script uses echo() to output the results? how to capture its output during request processing? besides, i do not like spawning another process for that and piping to it. it might not scale well. ;-)
please help. thanks konstantin
Another route is:
$sResponse = `php -q -d max_execution_t ime=60000
/path/to/php/file.php`;
In this example, I also add the "-d max_execution_t ime=60000" so that
your external script has a longer timeout time, in case you need that.
Note the backticks (`) in the code above -- these are not single
quotes.
I also don't do a direct path to PHP. If your $PATH already contains
the PHP bin path, then you might not need it.
Also, on my system, PHP is reached with /usr/bin/php instead of
/usr/local/bin/php. (I have RH9 Linux.)
konsu wrote: when a web request comes to my index.php, i would like index.php to execute a php script stored in an external file and capture the external script's output to a variable.
Is that script located on your system or somewhere else? If it
is local, (i.e., resides on your system), you can simply do
soomething like this:
$capture = file_get_conten ts('http://localhost/script.php');
If the external script is remote, you can do
$capture = file_get_conten ts('http://www.example.com/script.php');
Cheers,
NC This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Brian |
last post by:
Hi all.
I have a bunch of pages that reference an external script from the
head section. I'd like to add additional <script> elements to the
pages' bodies, but I can't edit the pages themselves. I'd like to add
them from the existing script, but I need to make sure that the
elements get added to the end of the document's body section.
Using document.write("<script ..."); the elements get added to the
head section! I'm trying to use...
|
by: Brian |
last post by:
Is it possible to set form event handlers in an external script (via
onload)? I've used a script to set onmouseover, but I get errors when I
try to set onreset from an external .js file with this function:
function addValidationToForm() {
document.forms.onreset = return confirm('reset form?');
document.forms.onsubmit = validateOnSubmit();
}
--
|
by: primary0 |
last post by:
Hi,
I have a page containing an external javascript which loads an image
onto the webpage. How would it be possible to use javascript to read
the filname (and the dimensions) of the loaded image (something I can
get by right-clicking the image with the mouse, but it is not given in
the source of the page).
|
by: Mellow Crow |
last post by:
Just discovered this technique. Is this old hat? Would there be any
disadvantage to doing this?
In your external .js file:
/*
Summary: includes external scripts in this external script
so that you don't have to reference them within the (x)html
document
files.
|
by: Deb M. |
last post by:
I am trying to find out how I can use the ASP.net framework yet still
post the variables to an external script (not ASPX) after the form has
been submitted. So, the ASPX page will still post to itself, but then
I need to transfer the variables to another page. I need to do this
transfer using the POST method and not the GET method.
I tried user Server.Transfer("http://localhost/test.asp") but it
retuns an error of...
| |
by: pseudomagazine |
last post by:
Little problem:
Using the document.write() function and an enormous string, I have managed to create self-generated pages with functions calling code located in external scripts. The code that generates these pages is linked to these pages from within the document.write() string. So far so good.
I lifted on the internet a supercode (flashobject.js) that detects Flash pluggin and loads Flash movies in id'ed <div> only in browsers equipped...
|
by: Pontifex |
last post by:
Hi all,
Has anyone devised a simple method for passing
a string to an external script?
For instance, suppose I want to produce a title bar
that is very fancy and I don't want my main HTML
file to be cluttered with the stuff that does that.
Can I pass a title string to an external script
|
by: John Smith |
last post by:
Hi All,
I have a script which reads a data file, reads the characters one by one and
if a certain character is meet it does something else, at the moment it
echos the fact that it meet a certain character.
I need it to take the characters it has read up to that point and present
them to a database field thats forms part of a set of fields that will be
updated at once. Then it will continue to read the remainder of the file and
repeat...
|
by: dreaken667 |
last post by:
I currently have a PHP script that pulls records from a table and runs PHP scripts based on the table entries, but it requires that I actually load the page in a browser and wait for it to complete. What I'd like to do is create a scheduled stored procedure that will do this for me. Unfortunately, all I can find on the net is how to run a stored procedure from PHP. What I'm looking for is how to accomplish the exact opposite. Does anyone know...
|
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...
|
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...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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();...
|
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...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |