Shelling without waiting 
September 5th, 2008, 11:35 AM
| | | Shelling without waiting
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 | 
September 5th, 2008, 12:25 PM
| | | 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(). | 
September 5th, 2008, 12:55 PM
| | | 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. | 
September 5th, 2008, 01:05 PM
| | | 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
| >>
<?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. | 
September 5th, 2008, 02:05 PM
| | | 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 | 
September 5th, 2008, 04:25 PM
| | | 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. | 
September 6th, 2008, 11:45 AM
| | | 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:
<?php
$started=`at now script.pl $arg`;
?>
| >>
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. | 
September 6th, 2008, 11:55 AM
| | | 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:
<?php
* $started=`at now script.pl $arg`;
?>
| | >> 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? | 
September 8th, 2008, 12:35 PM
| | | 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:
<?php
$started=`at now script.pl $arg`;
?>
| | >> 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.
| >>
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. | | Thread Tools | Search this Thread | | | |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | | | | What is Bytes?
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 220,989 network members.
|