Connecting Tech Pros Worldwide Forums | Help | Site Map

Shelling without waiting

Bill H
Guest
 
Posts: n/a
#1: Sep 5 '08
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

Sjoerd
Guest
 
Posts: n/a
#2: Sep 5 '08

re: Shelling without waiting


On Fri, 05 Sep 2008 04:28:16 -0700, Bill H wrote:
Quote:
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().
C. (http://symcbean.blogspot.com/)
Guest
 
Posts: n/a
#3: Sep 5 '08

re: Shelling without waiting


On 5 Sep, 12:28, Bill H <b...@ts1000.uswrote:
Quote:
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.
Captain Paralytic
Guest
 
Posts: n/a
#4: Sep 5 '08

re: Shelling without waiting


On 5 Sep, 13:46, "C. (http://symcbean.blogspot.com/)"
<colin.mckin...@gmail.comwrote:
Quote:
On 5 Sep, 12:28, Bill H <b...@ts1000.uswrote:
>
>
>
>
>
Quote:
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?
>
Quote:
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)?
>
Quote:
Any ideas, weblinks, documentation is appreciated
>
Quote:
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.
Bill H
Guest
 
Posts: n/a
#5: Sep 5 '08

re: Shelling without waiting


On Sep 5, 8:21*am, Sjoerd <sjoer...@gmail.comwrote:
Quote:
On Fri, 05 Sep 2008 04:28:16 -0700, Bill H wrote:
Quote:
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
RJ_32
Guest
 
Posts: n/a
#6: Sep 5 '08

re: Shelling without waiting


Bill H wrote:
Quote:
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.
C. (http://symcbean.blogspot.com/)
Guest
 
Posts: n/a
#7: Sep 6 '08

re: Shelling without waiting


On 5 Sep, 14:02, Captain Paralytic <paul_laut...@yahoo.comwrote:
Quote:
On 5 Sep, 13:46, "C. (http://symcbean.blogspot.com/)"
>
<colin.mckin...@gmail.comwrote:
Quote:
On 5 Sep, 12:28, Bill H <b...@ts1000.uswrote:
>
Quote:
Quote:
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?
>
Quote:
Quote:
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)?
>
Quote:
Quote:
Any ideas, weblinks, documentation is appreciated
>
Quote:
Quote:
Bill H
>
Quote:
<?php
$started=`at now script.pl $arg`;
?>
>
Quote:
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.
Captain Paralytic
Guest
 
Posts: n/a
#8: Sep 6 '08

re: Shelling without waiting


On Sep 6, 12:40*pm, "C. (http://symcbean.blogspot.com/)"
<colin.mckin...@gmail.comwrote:
Quote:
On 5 Sep, 14:02, Captain Paralytic <paul_laut...@yahoo.comwrote:
>
>
>
Quote:
On 5 Sep, 13:46, "C. (http://symcbean.blogspot.com/)"
>
Quote:
<colin.mckin...@gmail.comwrote:
Quote:
On 5 Sep, 12:28, Bill H <b...@ts1000.uswrote:
>
Quote:
Quote:
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?
>
Quote:
Quote:
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)?
>
Quote:
Quote:
Any ideas, weblinks, documentation is appreciated
>
Quote:
Quote:
Bill H
>
Quote:
Quote:
<?php
* $started=`at now script.pl $arg`;
?>
>
Quote:
Quote:
C
>
Quote:
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?
C. (http://symcbean.blogspot.com/)
Guest
 
Posts: n/a
#9: Sep 8 '08

re: Shelling without waiting


On 6 Sep, 12:48, Captain Paralytic <paul_laut...@yahoo.comwrote:
Quote:
On Sep 6, 12:40 pm, "C. (http://symcbean.blogspot.com/)"
>
>
>
<colin.mckin...@gmail.comwrote:
Quote:
On 5 Sep, 14:02, Captain Paralytic <paul_laut...@yahoo.comwrote:
>
Quote:
Quote:
On 5 Sep, 13:46, "C. (http://symcbean.blogspot.com/)"
>
Quote:
Quote:
<colin.mckin...@gmail.comwrote:
On 5 Sep, 12:28, Bill H <b...@ts1000.uswrote:
>
Quote:
Quote:
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?
>
Quote:
Quote:
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)?
>
Quote:
Quote:
Any ideas, weblinks, documentation is appreciated
>
Quote:
Quote:
Bill H
>
Quote:
Quote:
<?php
$started=`at now script.pl $arg`;
?>
>
Quote:
Quote:
C
>
Quote:
Quote:
That is the equivalent of shell_exec and it will still await the
completion of the command.
>
Quote:
No it won't: read it again.
>
Quote:
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.
Closed Thread