launch other script

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bob Bedford

    launch other script

    I've a script that must "launch" an other script on some situations.

    firstscript.php :
    ....
    If ($newarticle)
    //launch secondscript.ph p
    ....

    The "secondscript.p hp" may take quite long, and is not necessary in
    "firstscript.ph p" to wait until it's finished. So how to launch
    secondscipt.php and continue the script, without waiting it to finish.

    Thanks

    Bob


  • Simon Stienen

    #2
    Re: launch other script

    Bob Bedford <bedford1@YouKn owWhatToDoHereh otmail.com> wrote:[color=blue]
    > I've a script that must "launch" an other script on some situations.
    >
    > firstscript.php :
    > ...
    > If ($newarticle)
    > //launch secondscript.ph p
    > ...
    >
    > The "secondscript.p hp" may take quite long, and is not necessary in
    > "firstscript.ph p" to wait until it's finished. So how to launch
    > secondscipt.php and continue the script, without waiting it to finish.
    >
    > Thanks
    >
    > Bob[/color]

    Execute and dispatch it: exec('/path/to/php -f /path/to/otherscript.php[color=blue]
    >/dev/null 2>/dev/null &');[/color]
    Exact command line may differ depending on the installed shell.

    --
    Simon Stienen <http://dangerouscat.ne t> <http://slashlife.de>
    »What you do in this world is a matter of no consequence,
    The question is, what can you make people believe that you have done.«
    -- Sherlock Holmes in "A Study in Scarlet" by Sir Arthur Conan Doyle

    Comment

    • Nikolai Chuvakhin

      #3
      Re: launch other script

      "Bob Bedford" <bedford1@YouKn owWhatToDoHereh otmail.com>
      wrote in message news:<4152e181$ 0$21028$5402220 f@news.sunrise. ch>...[color=blue]
      >
      > I've a script that must "launch" an other script on some situations.
      >
      > firstscript.php :
      > ...
      > If ($newarticle)
      > //launch secondscript.ph p
      > ...
      >
      > The "secondscript.p hp" may take quite long, and is not necessary in
      > "firstscript.ph p" to wait until it's finished. So how to launch
      > secondscipt.php and continue the script, without waiting it to finish.[/color]

      You can do this, but you need administrator privileges on your
      server. You have two options:

      1. Launch the second script in the background via exec/wget:

      exec('wget http://server.com/path/secondscript.php ' .
      '--quiet -O /dev/null &');

      2. Launch the second script in the background via command-line
      interface:

      exec('php /path/secondscript.ph p &');

      Cheers,
      NC

      Comment

      • Bob Bedford

        #4
        Re: launch other script

        "Nikolai Chuvakhin" <nc@iname.com > a écrit dans le message de
        news:32d7a63c.0 409231119.67ecf 63a@posting.goo gle.com...[color=blue]
        > "Bob Bedford" <bedford1@YouKn owWhatToDoHereh otmail.com>
        > wrote in message news:<4152e181$ 0$21028$5402220 f@news.sunrise. ch>...[color=green]
        > >
        > > I've a script that must "launch" an other script on some situations.
        > >
        > > firstscript.php :
        > > ...
        > > If ($newarticle)
        > > //launch secondscript.ph p
        > > ...
        > >
        > > The "secondscript.p hp" may take quite long, and is not necessary in
        > > "firstscript.ph p" to wait until it's finished. So how to launch
        > > secondscipt.php and continue the script, without waiting it to finish.[/color]
        >
        > You can do this, but you need administrator privileges on your
        > server. You have two options:
        >
        > 1. Launch the second script in the background via exec/wget:
        >
        > exec('wget http://server.com/path/secondscript.php ' .
        > '--quiet -O /dev/null &');
        >
        > 2. Launch the second script in the background via command-line
        > interface:
        >
        > exec('php /path/secondscript.ph p &');
        >[/color]
        I've no EXEC right, or even system rights. how to do ?

        Bob


        Comment

        • Simon Stienen

          #5
          Re: launch other script

          Bob Bedford <bedford1@YouKn owWhatToDoHereh otmail.com> wrote:[color=blue]
          > "Nikolai Chuvakhin" <nc@iname.com > a écrit dans le message de
          > news:32d7a63c.0 409231119.67ecf 63a@posting.goo gle.com...[color=green]
          >> "Bob Bedford" <bedford1@YouKn owWhatToDoHereh otmail.com>
          >> wrote in message news:<4152e181$ 0$21028$5402220 f@news.sunrise. ch>...[color=darkred]
          >>>
          >>> I've a script that must "launch" an other script on some situations.
          >>>
          >>> firstscript.php :
          >>> ...
          >>> If ($newarticle)
          >>> //launch secondscript.ph p
          >>> ...
          >>>
          >>> The "secondscript.p hp" may take quite long, and is not necessary in
          >>> "firstscript.ph p" to wait until it's finished. So how to launch
          >>> secondscipt.php and continue the script, without waiting it to finish.[/color]
          >>
          >> You can do this, but you need administrator privileges on your
          >> server. You have two options:
          >>
          >> 1. Launch the second script in the background via exec/wget:
          >>
          >> exec('wget http://server.com/path/secondscript.php ' .
          >> '--quiet -O /dev/null &');
          >>
          >> 2. Launch the second script in the background via command-line
          >> interface:
          >>
          >> exec('php /path/secondscript.ph p &');
          >>[/color]
          > I've no EXEC right, or even system rights. how to do ?
          >
          > Bob[/color]

          humm... If you ignore connection aborts in the second script you could call
          it using Sockets... The request would be:

          -----BEGIN HTTP-REQUEST BLOCK-----
          GET /onlinepath/to/yourscript.php HTTP/1.1
          Host: www.yourserver.tld

          ------END HTTP-REQUEST BLOCK------
          , using \r\n as line break.
          Don't forget the empty line at the end (the query string will end with
          "\r\n\r\n") !
          --
          Simon Stienen <http://dangerouscat.ne t> <http://slashlife.de>
          »What you do in this world is a matter of no consequence,
          The question is, what can you make people believe that you have done.«
          -- Sherlock Holmes in "A Study in Scarlet" by Sir Arthur Conan Doyle

          Comment

          • harryman100

            #6
            Re: launch other script

            "Bob Bedford" <bedford1@YouKn owWhatToDoHereh otmail.com> wrote in message news:<4152e181$ 0$21028$5402220 f@news.sunrise. ch>...[color=blue]
            > I've a script that must "launch" an other script on some situations.
            >
            > firstscript.php :
            > ...
            > If ($newarticle)
            > //launch secondscript.ph p
            > ...
            >
            > The "secondscript.p hp" may take quite long, and is not necessary in
            > "firstscript.ph p" to wait until it's finished. So how to launch
            > secondscipt.php and continue the script, without waiting it to finish.[/color]

            Do you really need to continue processing the first script? Could you
            do all the necessary processing left in the first script and then use
            a header re-direct to the second script?

            Comment

            • Guest's Avatar

              #7
              Re: launch other script

              > I've a script that must "launch" an other script on some situations.

              In most cases the need to do something like this falls under two categories:
              1 - I need to pass the request on to another script because I am done with
              the current script
              Solution: Header() function.

              2 - I need to do some maintanance or cleanup such as deleting temp files, or
              removing stale entries from the database.
              Solution: External script or application that is run from the Cron Daemon or
              Windows Task Scheduler.

              I'd be surprised to find your problem falls under another category. Can you
              describe your needs further?

              _______________ _______________ ______
              Wil Moore III, MCP | Integrations Specialist


              Comment

              • Bob Bedford

                #8
                Re: launch other script

                > Do you really need to continue processing the first script? Could you[color=blue]
                > do all the necessary processing left in the first script and then use
                > a header re-direct to the second script?[/color]

                I'll explain:
                1- the user enter new article details for sell in script1.php
                2- the user clicks "submit" and the script call insert1.php
                3a- All customers who are looking for such article (on some criteria, color,
                price...) must be contacted by an email with a link pointing to the new
                article. the user doesn't need any information from here ! so it's an
                independent process.
                3b- insert1.php insert the article in the database and then inform the user
                that the article is inserted in the shop.

                3a should be executed when the script is submitted at point 2, but the user
                doesn't need any information from it, and since it takes a long time, it
                should be executed without the need to wait on it.
                3b is also submitted at the point 2, but it returns information, and must
                not wait until 3a is finished, as they are 2 different processes.

                How to launch 3a (3b is what appens now, but I don't know how to launch 3a
                without the need to wait is finished to continue).

                Bob


                Comment

                • Bob Bedford

                  #9
                  Re: launch other script

                  > 2 - I need to do some maintanance or cleanup such as deleting temp files,
                  or[color=blue]
                  > removing stale entries from the database.
                  > Solution: External script or application that is run from the Cron Daemon[/color]
                  or[color=blue]
                  > Windows Task Scheduler.[/color]


                  The exact point is the second one !!!

                  I've no CRON daemon possibility as I've no rights on the server (exec, cron,
                  system have been unactivated for security reasons). I may call a script from
                  house, with Task Scheduler, but it will be called on selected time, not when
                  a new article is inserted. I'd like the process to run when a new article is
                  inserted, not 2 hours later ! I'm also against to have my machine to run
                  24/24 7/7 for calling a script on a server. The process should be done
                  directly from the scripts themselves.

                  I'll explain what I need:
                  1- the user enter new article details for sell in script1.php
                  2- the user clicks "submit" and the script call insert1.php
                  3a- All customers who are looking for such article (on some criteria, color,
                  price...) must be contacted by an email with a link pointing to the new
                  article. the user doesn't need any information from here ! so it's an
                  independent process.
                  3b- insert1.php insert the article in the database and then inform the user
                  that the article is inserted in the shop.

                  3a should be executed when the script is submitted at point 2, but the user
                  doesn't need any information from it, and since it takes a long time, it
                  should be executed without the need to wait on it.
                  3b is also submitted at the point 2, but it returns information, and must
                  not wait until 3a is finished, as they are 2 different processes.

                  How to launch 3a (3b is what appens now, but I don't know how to launch 3a
                  without the need to wait is finished to continue).

                  Bob


                  Comment

                  Working...