By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,825 Members | 1,364 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,825 IT Pros & Developers. It's quick & easy.

launch other script

P: n/a
I've a script that must "launch" an other script on some situations.

firstscript.php:
....
If ($newarticle)
//launch secondscript.php
....

The "secondscript.php" may take quite long, and is not necessary in
"firstscript.php" to wait until it's finished. So how to launch
secondscipt.php and continue the script, without waiting it to finish.

Thanks

Bob
Jul 17 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Bob Bedford <be******@YouKnowWhatToDoHerehotmail.com> wrote:
I've a script that must "launch" an other script on some situations.

firstscript.php:
...
If ($newarticle)
//launch secondscript.php
...

The "secondscript.php" may take quite long, and is not necessary in
"firstscript.php" to wait until it's finished. So how to launch
secondscipt.php and continue the script, without waiting it to finish.

Thanks

Bob
Execute and dispatch it: exec('/path/to/php -f /path/to/otherscript.php/dev/null 2>/dev/null &');

Exact command line may differ depending on the installed shell.

--
Simon Stienen <http://dangerouscat.net> <http://slashlife.de>
»What you do in this world is a matter of no consequence,
The question is, what can you make people believe that you have done.«
-- Sherlock Holmes in "A Study in Scarlet" by Sir Arthur Conan Doyle
Jul 17 '05 #2

P: n/a
"Bob Bedford" <be******@YouKnowWhatToDoHerehotmail.com>
wrote in message news:<41***********************@news.sunrise.ch>.. .

I've a script that must "launch" an other script on some situations.

firstscript.php:
...
If ($newarticle)
//launch secondscript.php
...

The "secondscript.php" may take quite long, and is not necessary in
"firstscript.php" to wait until it's finished. So how to launch
secondscipt.php and continue the script, without waiting it to finish.


You can do this, but you need administrator privileges on your
server. You have two options:

1. Launch the second script in the background via exec/wget:

exec('wget http://server.com/path/secondscript.php ' .
'--quiet -O /dev/null &');

2. Launch the second script in the background via command-line
interface:

exec('php /path/secondscript.php &');

Cheers,
NC
Jul 17 '05 #3

P: n/a
"Nikolai Chuvakhin" <nc@iname.com> a écrit dans le message de
news:32**************************@posting.google.c om...
"Bob Bedford" <be******@YouKnowWhatToDoHerehotmail.com>
wrote in message news:<41***********************@news.sunrise.ch>.. .

I've a script that must "launch" an other script on some situations.

firstscript.php:
...
If ($newarticle)
//launch secondscript.php
...

The "secondscript.php" may take quite long, and is not necessary in
"firstscript.php" to wait until it's finished. So how to launch
secondscipt.php and continue the script, without waiting it to finish.


You can do this, but you need administrator privileges on your
server. You have two options:

1. Launch the second script in the background via exec/wget:

exec('wget http://server.com/path/secondscript.php ' .
'--quiet -O /dev/null &');

2. Launch the second script in the background via command-line
interface:

exec('php /path/secondscript.php &');

I've no EXEC right, or even system rights. how to do ?

Bob
Jul 17 '05 #4

P: n/a
Bob Bedford <be******@YouKnowWhatToDoHerehotmail.com> wrote:
"Nikolai Chuvakhin" <nc@iname.com> a écrit dans le message de
news:32**************************@posting.google.c om...
"Bob Bedford" <be******@YouKnowWhatToDoHerehotmail.com>
wrote in message news:<41***********************@news.sunrise.ch>.. .

I've a script that must "launch" an other script on some situations.

firstscript.php:
...
If ($newarticle)
//launch secondscript.php
...

The "secondscript.php" may take quite long, and is not necessary in
"firstscript.php" to wait until it's finished. So how to launch
secondscipt.php and continue the script, without waiting it to finish.


You can do this, but you need administrator privileges on your
server. You have two options:

1. Launch the second script in the background via exec/wget:

exec('wget http://server.com/path/secondscript.php ' .
'--quiet -O /dev/null &');

2. Launch the second script in the background via command-line
interface:

exec('php /path/secondscript.php &');

I've no EXEC right, or even system rights. how to do ?

Bob


humm... If you ignore connection aborts in the second script you could call
it using Sockets... The request would be:

-----BEGIN HTTP-REQUEST BLOCK-----
GET /onlinepath/to/yourscript.php HTTP/1.1
Host: www.yourserver.tld

------END HTTP-REQUEST BLOCK------
, using \r\n as line break.
Don't forget the empty line at the end (the query string will end with
"\r\n\r\n")!
--
Simon Stienen <http://dangerouscat.net> <http://slashlife.de>
»What you do in this world is a matter of no consequence,
The question is, what can you make people believe that you have done.«
-- Sherlock Holmes in "A Study in Scarlet" by Sir Arthur Conan Doyle
Jul 17 '05 #5

P: n/a
"Bob Bedford" <be******@YouKnowWhatToDoHerehotmail.com> wrote in message news:<41***********************@news.sunrise.ch>.. .
I've a script that must "launch" an other script on some situations.

firstscript.php:
...
If ($newarticle)
//launch secondscript.php
...

The "secondscript.php" may take quite long, and is not necessary in
"firstscript.php" to wait until it's finished. So how to launch
secondscipt.php and continue the script, without waiting it to finish.


Do you really need to continue processing the first script? Could you
do all the necessary processing left in the first script and then use
a header re-direct to the second script?
Jul 17 '05 #6

P: n/a
> I've a script that must "launch" an other script on some situations.

In most cases the need to do something like this falls under two categories:
1 - I need to pass the request on to another script because I am done with
the current script
Solution: Header() function.

2 - I need to do some maintanance or cleanup such as deleting temp files, or
removing stale entries from the database.
Solution: External script or application that is run from the Cron Daemon or
Windows Task Scheduler.

I'd be surprised to find your problem falls under another category. Can you
describe your needs further?

____________________________________
Wil Moore III, MCP | Integrations Specialist
Jul 17 '05 #7

P: n/a
> Do you really need to continue processing the first script? Could you
do all the necessary processing left in the first script and then use
a header re-direct to the second script?


I'll explain:
1- the user enter new article details for sell in script1.php
2- the user clicks "submit" and the script call insert1.php
3a- All customers who are looking for such article (on some criteria, color,
price...) must be contacted by an email with a link pointing to the new
article. the user doesn't need any information from here ! so it's an
independent process.
3b- insert1.php insert the article in the database and then inform the user
that the article is inserted in the shop.

3a should be executed when the script is submitted at point 2, but the user
doesn't need any information from it, and since it takes a long time, it
should be executed without the need to wait on it.
3b is also submitted at the point 2, but it returns information, and must
not wait until 3a is finished, as they are 2 different processes.

How to launch 3a (3b is what appens now, but I don't know how to launch 3a
without the need to wait is finished to continue).

Bob
Jul 17 '05 #8

P: n/a
> 2 - I need to do some maintanance or cleanup such as deleting temp files,
or
removing stale entries from the database.
Solution: External script or application that is run from the Cron Daemon or Windows Task Scheduler.

The exact point is the second one !!!

I've no CRON daemon possibility as I've no rights on the server (exec, cron,
system have been unactivated for security reasons). I may call a script from
house, with Task Scheduler, but it will be called on selected time, not when
a new article is inserted. I'd like the process to run when a new article is
inserted, not 2 hours later ! I'm also against to have my machine to run
24/24 7/7 for calling a script on a server. The process should be done
directly from the scripts themselves.

I'll explain what I need:
1- the user enter new article details for sell in script1.php
2- the user clicks "submit" and the script call insert1.php
3a- All customers who are looking for such article (on some criteria, color,
price...) must be contacted by an email with a link pointing to the new
article. the user doesn't need any information from here ! so it's an
independent process.
3b- insert1.php insert the article in the database and then inform the user
that the article is inserted in the shop.

3a should be executed when the script is submitted at point 2, but the user
doesn't need any information from it, and since it takes a long time, it
should be executed without the need to wait on it.
3b is also submitted at the point 2, but it returns information, and must
not wait until 3a is finished, as they are 2 different processes.

How to launch 3a (3b is what appens now, but I don't know how to launch 3a
without the need to wait is finished to continue).

Bob
Jul 17 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.