Professional Web Applications Themes

Need help w/ system, exec, or proc_open - PHP Development

Im not even sure which on i should be using, but hear is my situation. From within my php script I need to run another program and put it in the background... I thought that doing exec("/usr/local/bin/someapp &") would do it, but it dosn't... This program should be througn in the background (it has an endless loop and dosn't want user imput or anything). after this program has started, my php script needs to wait for 5 seconds, and continue running. at the end of the script I need to kill the program i originally started... Can anyone help me ...

  1. #1

    Default Need help w/ system, exec, or proc_open

    Im not even sure which on i should be using, but hear is my situation. From within my php script I need to run another program and put it in
    the background... I thought that doing exec("/usr/local/bin/someapp &") would do it, but it dosn't...


    This program should be througn in the background (it has an endless loop and dosn't want user imput or anything).
    after this program has started, my php script needs to wait for 5 seconds, and continue running.

    at the end of the script I need to kill the program i originally started...
    Can anyone help me out with this???


    here is my perl equivilent:

    system("myapp \&");
    sleep 5;

    .... ..... ....

    system("killall -9 myapp");


    Thank you
    DC Guest

  2. #2

    Default Re: Need help w/ system, exec, or proc_open

    DC wrote:
     

    Correct me if i'm wrong, but afaik the php interpreter only continues
    when the exec'd program has quit, so it won't work with a program that
    lasts in a while(1) loop to go further in the php script and leave the
    exec'd thingy alone...
    Thomas Guest

  3. #3

    Default Re: Need help w/ system, exec, or proc_open

    On Fri, 26 Aug 2005 18:04:37 +0200, Thomas Bader <at> wrote:
     
    >
    >Correct me if i'm wrong, but afaik the php interpreter only continues
    >when the exec'd program has quit, so it won't work with a program that
    >lasts in a while(1) loop to go further in the php script and leave the
    >exec'd thingy alone...[/ref]


    Thats exactly the trouble im having, but I cannot believe that there is no way around it. Granted I could make a shell script that runs the
    program in the background, then the php script, and then kills the program again... Thats just getting sloppy, I would like to have it all
    contained in one php script.
    DC Guest

  4. #4

    Default Re: Need help w/ system, exec, or proc_open

    DC wrote:
     

    I'm afraid but since PHP interpreter works sequentially i guess thats a
    mission impossible :/
    Thomas Guest

  5. #5

    Default Re: Need help w/ system, exec, or proc_open

    On Fri, 26 Aug 2005 19:00:49 +0200, Thomas Bader <at> wrote:
     
    >
    >I'm afraid but since PHP interpreter works sequentially i guess thats a
    >mission impossible :/[/ref]


    There has to be a way... Perl works sequentially and it has no problem doing it. Im trying to see if can get it with a simple exec command
    rather then dealing with forks.
    DC Guest

Similar Threads

  1. Qn regd exec() system call
    By Karthik in forum UNIX Programming
    Replies: 7
    Last Post: February 7th, 01:20 PM
  2. [PHP] Issues with exec()/system()
    By Curt Zirzow in forum PHP Development
    Replies: 0
    Last Post: September 10th, 04:21 PM
  3. system, `` or exec on Windows?
    By Chris Morris in forum Ruby
    Replies: 2
    Last Post: July 17th, 06:56 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139