Triggering a script from another script

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Emanuele D'Arrigo

    Triggering a script from another script

    Dear readers of comp.lang.php,

    I recently finished a script for a website, and altough
    I'm happy with it, it's a bit too slow, due to the many
    and somewhat complex queries to a MySQL database.

    This has been partially solved writing the script so
    that only the first person after midnight that requests
    that page actually generates it. Everybody else will
    get the stored html file out of that first request until
    the next midnight.

    A new opportunity has arisen though, because altough another
    person would have to set it up, now it would be possible to
    run a script through a cronjob.

    Ideally, to avoid touching the first script, I'd write a
    second, to be run through cronjob, that act like a browser
    and triggers the page generation sometime after midnight.

    I therefore tried something simple like this:

    ----
    #!/usr/sbin/php

    <?php

    header("Locatio n: http://www.euroharmony .com/~manu/hubstats2.php?w hich=ESSA&page4 &force=1");


    exit;

    ?>
    ----

    But it doesn't actually do anything else other than print out

    Location: http://www.euroharmony.com/~manu/hub...&page4&force=1
    Content-type: text/html

    What should I do instead? Am I using the wrong command?
    Any hint? tip? trick?

    Thank you!

    Manu
  • David Mackenzie

    #2
    Re: Triggering a script from another script

    On 21 Oct 2003 03:54:55 -0700, manu3d@mclink.i t (Emanuele D'Arrigo)
    wrote:
    [color=blue]
    >Ideally, to avoid touching the first script, I'd write a
    >second, to be run through cronjob, that act like a browser
    >and triggers the page generation sometime after midnight.[/color]

    Just call your script from the command line:

    /path/to/php /path/to/your/script.php

    No need for a second script.

    I've used this with crontab without any problem (to send daily
    e-mails).

    --
    David ( @priz.co.uk )
    The Internet Prisoner Database: http://www.priz.co.uk/ipdb/
    The Tarbrax Chronicle: http://www.tarbraxchronicle.com/

    Comment

    • Emanuele D'Arrigo

      #3
      Re: Triggering a script from another script

      > Just call your script from the command line:[color=blue]
      > /path/to/php /path/to/your/script.php
      > No need for a second script.[/color]

      Yep, this is the way to run any script from
      command line, but as you might have noticed
      from the URLs above, I pass a few parameters
      through the URL.

      This means that I'd have to change the first
      script to handle command-line style arguments,
      which I'm trying to avoid.

      Manu

      Comment

      • David Mackenzie

        #4
        Re: Triggering a script from another script

        On 22 Oct 2003 03:26:37 -0700, manu3d@mclink.i t (Emanuele D'Arrigo)
        wrote:
        [color=blue][color=green]
        >> Just call your script from the command line:
        >> /path/to/php /path/to/your/script.php
        >> No need for a second script.[/color]
        >
        >Yep, this is the way to run any script from
        >command line, but as you might have noticed
        >from the URLs above, I pass a few parameters
        >through the URL.[/color]

        Oops. Didn't spot that.
        [color=blue]
        >This means that I'd have to change the first
        >script to handle command-line style arguments,
        >which I'm trying to avoid.[/color]

        Look at wget or lynx.

        --
        David ( @priz.co.uk )
        The Internet Prisoner Database: http://www.priz.co.uk/ipdb/
        The Tarbrax Chronicle: http://www.tarbraxchronicle.com/

        Comment

        Working...