Connecting Tech Pros Worldwide Help | Site Map

Shelling without waiting

 
LinkBack Thread Tools Search this Thread
  #1  
Old September 5th, 2008, 11:35 AM
Bill H
Guest
 
Posts: n/a
Default 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

  #2  
Old September 5th, 2008, 12:25 PM
Sjoerd
Guest
 
Posts: n/a
Default 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, 12:55 PM
C. (http://symcbean.blogspot.com/)
Guest
 
Posts: n/a
Default 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, 01:05 PM
Captain Paralytic
Guest
 
Posts: n/a
Default 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, 02:05 PM
Bill H
Guest
 
Posts: n/a
Default 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, 04:25 PM
RJ_32
Guest
 
Posts: n/a
Default 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, 11:45 AM
C. (http://symcbean.blogspot.com/)
Guest
 
Posts: n/a
Default 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, 11:55 AM
Captain Paralytic
Guest
 
Posts: n/a
Default 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, 12:35 PM
C. (http://symcbean.blogspot.com/)
Guest
 
Posts: n/a
Default 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.
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

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.