Connecting Tech Pros Worldwide Help | Site Map

Shelling without waiting

  #1  
Old September 5th, 2008, 12:35 PM
Bill H
Guest
 
Posts: 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
  #2  
Old September 5th, 2008, 01:25 PM
Sjoerd
Guest
 
Posts: n/a

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().
  #3  
Old September 5th, 2008, 01:55 PM
C. (http://symcbean.blogspot.com/)
Guest
 
Posts: n/a

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.
  #4  
Old September 5th, 2008, 02:05 PM
Captain Paralytic
Guest
 
Posts: n/a

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.
  #5  
Old September 5th, 2008, 03:05 PM
Bill H
Guest
 
Posts: n/a

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
  #6  
Old September 5th, 2008, 05:25 PM
RJ_32
Guest
 
Posts: n/a

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.
  #7  
Old September 6th, 2008, 12:45 PM
C. (http://symcbean.blogspot.com/)
Guest
 
Posts: n/a

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.
  #8  
Old September 6th, 2008, 12:55 PM
Captain Paralytic
Guest
 
Posts: n/a

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?
  #9  
Old September 8th, 2008, 01:35 PM
C. (http://symcbean.blogspot.com/)
Guest
 
Posts: n/a

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
help required. kaps answers 36 June 27th, 2008 08:35 PM
How do you execute an OS X application (bundle) from Python? David Hughes answers 17 July 18th, 2005 06:23 PM