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

Shelling without waiting

P: n/a
In a php script I am using I need to call an external program and have
it start running, but I don't want the php script to wait for it to
finish. Looking at exec() and system() these would all seem to wait
for the external program to complete before they came back. Is there a
way of doing this without waiting for the results?

The program I want to run is a perl script that takes data stored by
the php program and then creates pdf's and preview images of these.
Instead of the php (and user) waiting the 15 seconds or more for this
to happen, I want to call this external program and then let the user
(via flash and php) poll the server to see if it is done. When I was
doing this in perl alone I was able to flush out the results of the
flash post back to flash and then the perl could just grind along till
it was done, is this a possible scenario in php (though I would prefer
the 1st scenerio of starting the external program and leaving)?

Any ideas, weblinks, documentation is appreciated

Bill H
Sep 5 '08 #1
Share this Question
Share on Google+
8 Replies


P: n/a
On Fri, 05 Sep 2008 04:28:16 -0700, Bill H wrote:
Looking at exec() and system() these would all seem to wait for
the external program to complete before they came back. Is there a way
of doing this without waiting for the results?
May you can do a fork() before doing an exec().
Sep 5 '08 #2

P: n/a
On 5 Sep, 12:28, Bill H <b...@ts1000.uswrote:
In a php script I am using I need to call an external program and have
it start running, but I don't want the php script to wait for it to
finish. Looking at exec() and system() these would all seem to wait
for the external program to complete before they came back. Is there a
way of doing this without waiting for the results?

The program I want to run is a perl script that takes data stored by
the php program and then creates pdf's and preview images of these.
Instead of the php (and user) waiting the 15 seconds or more for this
to happen, I want to call this external program and then let the user
(via flash and php) poll the server to see if it is done. When I was
doing this in perl alone I was able to flush out the results of the
flash post back to flash and then the perl could just grind along till
it was done, is this a possible scenario in php (though I would prefer
the 1st scenerio of starting the external program and leaving)?

Any ideas, weblinks, documentation is appreciated

Bill H
<?php
$started=`at now script.pl $arg`;
?>

C.
Sep 5 '08 #3

P: n/a
On 5 Sep, 13:46, "C. (http://symcbean.blogspot.com/)"
<colin.mckin...@gmail.comwrote:
On 5 Sep, 12:28, Bill H <b...@ts1000.uswrote:


In a php script I am using I need to call an external program and have
it start running, but I don't want the php script to wait for it to
finish. Looking at exec() and system() these would all seem to wait
for the external program to complete before they came back. Is there a
way of doing this without waiting for the results?
The program I want to run is a perl script that takes data stored by
the php program and then creates pdf's and preview images of these.
Instead of the php (and user) waiting the 15 seconds or more for this
to happen, I want to call this external program and then let the user
(via flash and php) poll the server to see if it is done. When I was
doing this in perl alone I was able to flush out the results of the
flash post back to flash and then the perl could just grind along till
it was done, is this a possible scenario in php (though I would prefer
the 1st scenerio of starting the external program and leaving)?
Any ideas, weblinks, documentation is appreciated
Bill H

<?php
* $started=`at now script.pl $arg`;
?>

C
That is the equivalent of shell_exec and it will still await the
completion of the command.
Sep 5 '08 #4

P: n/a
On Sep 5, 8:21*am, Sjoerd <sjoer...@gmail.comwrote:
On Fri, 05 Sep 2008 04:28:16 -0700, Bill H wrote:
Looking at exec() and system() these would all seem to wait for
the external program to complete before they came back. Is there a way
of doing this without waiting for the results?

May you can do a fork() before doing an exec().
I thought of this Sjoerd, but it doesn't seem to be what I am looking
for. A solution I thought of, but it isn't elegant, is to shell_exec()
an intemediatary perl program that would then start up the real script
in the background. The intemediatary program would return immediately
to php once it started the other one. But this seems to be too much of
a kludge.

Bill H
Sep 5 '08 #5

P: n/a
Bill H wrote:
In a php script I am using I need to call an external program and have
it start running, but I don't want the php script to wait for it to
finish.
resource popen ( string command, string mode )
Opens a pipe to a process executed by forking the command given by command.
Sep 5 '08 #6

P: n/a
On 5 Sep, 14:02, Captain Paralytic <paul_laut...@yahoo.comwrote:
On 5 Sep, 13:46, "C. (http://symcbean.blogspot.com/)"

<colin.mckin...@gmail.comwrote:
On 5 Sep, 12:28, Bill H <b...@ts1000.uswrote:
In a php script I am using I need to call an external program and have
it start running, but I don't want the php script to wait for it to
finish. Looking at exec() and system() these would all seem to wait
for the external program to complete before they came back. Is there a
way of doing this without waiting for the results?
The program I want to run is a perl script that takes data stored by
the php program and then creates pdf's and preview images of these.
Instead of the php (and user) waiting the 15 seconds or more for this
to happen, I want to call this external program and then let the user
(via flash and php) poll the server to see if it is done. When I was
doing this in perl alone I was able to flush out the results of the
flash post back to flash and then the perl could just grind along till
it was done, is this a possible scenario in php (though I would prefer
the 1st scenerio of starting the external program and leaving)?
Any ideas, weblinks, documentation is appreciated
Bill H
<?php
$started=`at now script.pl $arg`;
?>
C

That is the equivalent of shell_exec and it will still await the
completion of the command.
No it won't: read it again.

C.
Sep 6 '08 #7

P: n/a
On Sep 6, 12:40*pm, "C. (http://symcbean.blogspot.com/)"
<colin.mckin...@gmail.comwrote:
On 5 Sep, 14:02, Captain Paralytic <paul_laut...@yahoo.comwrote:
On 5 Sep, 13:46, "C. (http://symcbean.blogspot.com/)"
<colin.mckin...@gmail.comwrote:
On 5 Sep, 12:28, Bill H <b...@ts1000.uswrote:
In a php script I am using I need to call an external program and have
it start running, but I don't want the php script to wait for it to
finish. Looking at exec() and system() these would all seem to wait
for the external program to complete before they came back. Is there a
way of doing this without waiting for the results?
The program I want to run is a perl script that takes data stored by
the php program and then creates pdf's and preview images of these.
Instead of the php (and user) waiting the 15 seconds or more for this
to happen, I want to call this external program and then let the user
(via flash and php) poll the server to see if it is done. When I was
doing this in perl alone I was able to flush out the results of the
flash post back to flash and then the perl could just grind along till
it was done, is this a possible scenario in php (though I would prefer
the 1st scenerio of starting the external program and leaving)?
Any ideas, weblinks, documentation is appreciated
Bill H
<?php
* $started=`at now script.pl $arg`;
?>
C
That is the equivalent of shell_exec and it will still await the
completion of the command.

No it won't: read it again.

C.
shell_exec Execute command via shell and return the complete output
as a string

How can the complete output be returned if it does not await the
completion of the command?
Sep 6 '08 #8

P: n/a
On 6 Sep, 12:48, Captain Paralytic <paul_laut...@yahoo.comwrote:
On Sep 6, 12:40 pm, "C. (http://symcbean.blogspot.com/)"

<colin.mckin...@gmail.comwrote:
On 5 Sep, 14:02, Captain Paralytic <paul_laut...@yahoo.comwrote:
On 5 Sep, 13:46, "C. (http://symcbean.blogspot.com/)"
<colin.mckin...@gmail.comwrote:
On 5 Sep, 12:28, Bill H <b...@ts1000.uswrote:
In a php script I am using I need to call an external program andhave
it start running, but I don't want the php script to wait for it to
finish. Looking at exec() and system() these would all seem to wait
for the external program to complete before they came back. Is there a
way of doing this without waiting for the results?
The program I want to run is a perl script that takes data storedby
the php program and then creates pdf's and preview images of these.
Instead of the php (and user) waiting the 15 seconds or more for this
to happen, I want to call this external program and then let the user
(via flash and php) poll the server to see if it is done. When I was
doing this in perl alone I was able to flush out the results of the
flash post back to flash and then the perl could just grind alongtill
it was done, is this a possible scenario in php (though I would prefer
the 1st scenerio of starting the external program and leaving)?
Any ideas, weblinks, documentation is appreciated
Bill H
<?php
$started=`at now script.pl $arg`;
?>
C
That is the equivalent of shell_exec and it will still await the
completion of the command.
No it won't: read it again.
C.

shell_exec Execute command via shell and return the complete output
as a string

How can the complete output be returned if it does not await the
completion of the command?
man at

C.
Sep 8 '08 #9

This discussion thread is closed

Replies have been disabled for this discussion.