Scheduling PHP on Win XP

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Csaba Gabor

    Scheduling PHP on Win XP

    I would like to use the AT command under Win XP to schedule (CLI)
    php.exe. I thought it would be as easy as: AT 7:11 "php
    c:\phpapps\himo m.php". However, this gives me an error. My solution
    is inducing the gag reflex in me, so perhaps someone can point out an
    improvement.

    himom.php (to show a Message Box) looks like so:
    <?php
    function popup ($text, $title="PHP popup", $timeout=4, $style=131120) {
    $oWSH = new COM("WScript.Sh ell");
    if (is_null($text) ) $text = "NULL";
    $oWSH->Popup($text, $timeout, $title, $style); }
    popup("Hi mom"); // proof of access
    ?>


    So I wrote a single line c:\phpapps\himo m.vbs like so:
    MsgBox("Hi mother")

    and scheduled it like so: AT 7:15 /INTERACTIVE "c:\phpapps\him om.vbs"
    This worked and I got the expected (Hi mother) Message Box


    I now rewrote himom.vbs as follows:
    // First 4 lines get the directory that himom.vbs is in
    Set oWsh = WScript.CreateO bject("WScript. Shell")
    baseDir = WScript.ScriptF ullName
    pos = InStrRev (baseDir, "\")
    baseDir = mid(baseDir,1,p os)
    // Now dispatch to himom.php in the same directory
    Set oShell = CreateObject("W Script.Shell")
    oWsh.Run "php " & baseDir & "\" & "himom.php",0,f alse

    and scheduled it like so: AT 7:23 "c:\phpapps\him om.vbs"
    This time I got the "Hi mom" Message Box (from PHP). Note that the
    VBScript MsgBox requires the /INTERACTIVE flag, but the PHP popup does
    not. Regardless, this solution leaves me far from the warm fuzzies.
    Can anyone tell me the proper way to invoke a php app using AT?

    Thanks,
    Csaba Gabor from Vienna

    Motivation: I will be getting incoming requests to my server (with php
    running as a module under Apache 2). Certain requests will require me
    to schedule php.exe (CLI) to run an information retrieval program at a
    later point in time (up to 10 days later).

  • NC

    #2
    Re: Scheduling PHP on Win XP

    Csaba Gabor wrote:[color=blue]
    >
    > I would like to use the AT command under Win XP to schedule (CLI)
    > php.exe. I thought it would be as easy as: AT 7:11 "php
    > c:\phpapps\himo m.php". However, this gives me an error.[/color]

    Most likely, this is because you are trying to run the CGI executable.
    Try specifying the full path to the command-line interpreter:

    AT 7:11 "C:\php\cli\php .exe c:\phpapps\himo m.php"

    Cheers,
    NC

    Comment

    • Andrew DeFaria

      #3
      Re: Scheduling PHP on Win XP

      Csaba Gabor wrote:
      [color=blue]
      > Note that the VBScript MsgBox requires the /INTERACTIVE flag, but the
      > PHP popup does not.[/color]

      What gave you that notion? /interactive for the at command is required
      if the scheduled task wants to interact (hence the name) with the desktop.

      BTW: at is old hat. See Help & Support and search for schtasks.

      Comment

      • Csaba Gabor

        #4
        Re: Scheduling PHP on Win XP

        NC wrote:[color=blue]
        > Csaba Gabor wrote:[color=green]
        > >
        > > I would like to use the AT command under Win XP to schedule (CLI)
        > > php.exe. I thought it would be as easy as: AT 7:11 "php
        > > c:\phpapps\himo m.php". However, this gives me an error.[/color]
        >
        > Most likely, this is because you are trying to run the CGI executable.
        > Try specifying the full path to the command-line interpreter:
        >
        > AT 7:11 "C:\php\cli\php .exe c:\phpapps\himo m.php"[/color]

        Thanks for your response. However, I had tried specifying the complete
        executable path, and also the complete path to php-win and php-cgi.
        All silently fail for me. Does this same test work on your system (and
        if you make the test, please specify your system)?

        Csaba

        Comment

        • Csaba Gabor

          #5
          Re: Scheduling PHP on Win XP


          Andrew DeFaria wrote:[color=blue]
          > Csaba Gabor wrote:
          >[color=green]
          > > Note that the VBScript MsgBox requires the /INTERACTIVE flag, but the
          > > PHP popup does not.[/color]
          >
          > What gave you that notion?[/color]

          Testing.
          [color=blue]
          > /interactive for the at command is required if the scheduled
          > task wants to interact (hence the name) with the desktop.[/color]

          Yes, I have read this also in the AT help. Nevertheless, on my
          system, things happened as I reported in my original post. Do
          the tests turn out differently on yours?
          [color=blue]
          > BTW: at is old hat. See Help & Support and search for schtasks.[/color]

          Thank you for this. I have tested with schtasks using the following
          line, and the php script executed fine:
          C:\somedir>scht asks /create /SC once /TN test /TR
          "c:\winapps\php .net\php
          ..exe c:\phpapps\himo m.php" /ST 10:58:05 /RU system

          An aside about schtasks: it seems to require that you specify HH:MM:SS,
          but it sets the SS part to 00. Thus, if the minute has just turned and
          you want to schedule something 15 seconds from now, it will schedule as
          never since the SS=00 will ensure that time has passed. So I have to
          wonder why they force inclusion of seconds in the first place.

          Csaba

          PS. I would like to share a suggestion from Mark (thanks) that is in
          the vein of my original himom.vbs example:
          AT 11:36 explorer.exe http://localhost/himom.php

          This 'worked' but there seems to be a huge overhead. Whereas the
          performance using the himom.vbs funnel method was spiffy, with this
          method, it took several seconds for the popup to appear, and even after
          I had dismissed it, system usage stayed at around 50% for about a
          minute.

          Comment

          • Mark ??;-\)

            #6
            Re: Scheduling PHP on Win XP

            [color=blue]
            > PS. I would like to share a suggestion from Mark (thanks) that is in
            > the vein of my original himom.vbs example:
            > AT 11:36 explorer.exe http://localhost/himom.php
            >
            > This 'worked' but there seems to be a huge overhead. Whereas the
            > performance using the himom.vbs funnel method was spiffy, with this
            > method, it took several seconds for the popup to appear, and even after
            > I had dismissed it, system usage stayed at around 50% for about a
            > minute.[/color]

            Did you use explorer.exe or iexplore.exe? There may be a slight performance
            difference between the two.

            I should have posted to the group, my error. Here is the post:
            You could use AT to schedule Internet Explorer to load the desired PHP page.
            Like AT 7:23 iexplore.exe "path to your php page"



            -Mark


            Comment

            • Andrew DeFaria

              #7
              Re: Scheduling PHP on Win XP

              Csaba Gabor wrote:
              [color=blue]
              > Andrew DeFaria wrote:
              >[color=green]
              >> Csaba Gabor wrote:
              >>[color=darkred]
              >>> Note that the VBScript MsgBox requires the /INTERACTIVE flag, but
              >>> the PHP popup does not.[/color]
              >>
              >> What gave you that notion?[/color]
              >
              > Testing.
              >[color=green]
              >> /interactive for the at command is required if the scheduled task
              >> wants to interact (hence the name) with the desktop.[/color]
              >
              > Yes, I have read this also in the AT help. Nevertheless, on my system,
              > things happened as I reported in my original post. Do the tests turn
              > out differently on yours?[/color]

              Why would I bother? I simply use Cygiwn and cron. YMMV.


              Comment

              Working...