473,378 Members | 1,400 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,378 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 10147
"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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
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...

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.