473,394 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Launching a background script from php in Windows/IIS

Bob
Hi,

I'm trying to build a PHP page which launches another php script to be run
in the background. The web page should return immediately, while the
background script may run for 10 minutes or something. Unfortunately I'm
getting all kinds of weird behaviour..

In my main script I'm using exec() (also tried the other options) to start a
..bat file. This actually works, the batch file is launched and is able to
write something to disk.. Now if I put the following line in the batch file:

c:\php\php.exe -q backgroundscript.php

then instantly I'm seeing about 30 php.exe processes being created, but
nothing seems to be happening really. The processes seem to be dying
immediately and replaced by new ones. So apparently php is trying something
but fails and tries again.

Both the script and the batch file work fine from the command line. Group
'Everyone' has read/execute rights for the batch file, the php script and
php.exe. I have tried prefixing the command with START /b or cmd.exe /c but
neither seem to make any difference. Also I tried redirecting stderr, stdout
and stdin to NUL

Server is Win2k, IIS5, php4.3.0. Searched the php docs, tried suggestions
but it doesn't work, maybe because they use Apache.

My guess is that the anonymous user IUSR_* doesn't have the rights to do
something, but I can't figure out what. Please help me if you have an idea..

Bob
Jul 16 '05 #1
2 10149
"Bob" <no****@nospam.com> wrote in message
news:<bj**********@news.cistron.nl>...

I'm trying to build a PHP page which launches another php script
to be run in the background. .... Now if I put the following line in the batch file:

c:\php\php.exe -q backgroundscript.php


....you would be launching the wrong interpreter. The command-line
interpreter on Windows is not c:\php\php.exe, but, rather,
c:\php\cli\php.exe

Cheers,
NC
Jul 16 '05 #2
Bob
Nikolai,

Thanks alot, you saved my day!

I still had trouble to run the script in the background, PHP seemed to
insist on waiting for the background script to terminate. Finally got it
working by following this comment in the php docs:

# I used the bgrun-exe (www.jukkis.net/bgrun/bgrun.exe) to get this
working.
# I just put this file in my php directory (d:\php)
# This is my start.php file:
# $tmp=exec("d:\php\bgrun d:\php\cli\php -q d:\www\myphpapp.php
nul",$res);
Bob

"Nikolai Chuvakhin" <nc@iname.com> wrote in message
news:32**************************@posting.google.c om... "Bob" <no****@nospam.com> wrote in message
news:<bj**********@news.cistron.nl>...

I'm trying to build a PHP page which launches another php script
to be run in the background.

...
Now if I put the following line in the batch file:

c:\php\php.exe -q backgroundscript.php


...you would be launching the wrong interpreter. The command-line
interpreter on Windows is not c:\php\php.exe, but, rather,
c:\php\cli\php.exe

Cheers,
NC

Jul 16 '05 #3

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

Similar topics

3
by: Harlin Seritt | last post by:
Hi, I have a script.py that is converted to .exe using py2exe. From another script I call script.exe and would like to be able to run this script.exe in the background (as well as in console --...
6
by: Francois Bonzon | last post by:
Any idea how I can launch a background task from a PHP script? For example, when a user posts on my message board, it may fire many e-mail notifications to other users, and other tasks. I want...
5
by: JDS | last post by:
Hi. I have installed the PCNTL functions on my PHP enabled webserver in the interest of being able to fork a process into the background so I can do some heavy processing but return control of the...
10
by: Andrew Neiderer | last post by:
I think I am asking the right newsgroup. If not maybe someone could tell me where to ask this "beginner" question. I want to click on an image (.jpg) that launches a Microsoft window (cmd.exe...
8
by: =?iso-8859-1?B?QW5kcuk=?= | last post by:
I would like to find out how I can launch an independent Python program from existing one in a cross-platform way. The result I am after is that a new terminal window should open (for io...
5
by: John A. Bailo | last post by:
From a Windows service (NET 2.0) I want to launch serveral threads in a for loop that invokes a method using: new Thread(delegate() { myMethod(248);}).Start(); Will those threads stay...
5
by: Oriane | last post by:
Hi there, I would like to run a javascript file directly from the desktop, like a VBScript file. So my post is perhaps "out of topic" in which case I apologize. The goal is to run this sort...
5
by: Stef Mientki | last post by:
hello, I'm not familiar with Linux / Ubuntu, still trying to get my application working under these operating systems. I've a script "file_support.py", now when I'm in Ubuntu, open a command...
1
by: Paradox4 | last post by:
Hi, I'm converting an existing Perl script from UNIX to Windows XP. This script calls another Perl script in the background using backticks and ampersand (`x_child.pl ... &`). The child...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
jinu1996
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.