SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast Jujubee's Avatar
    Join Date
    Mar 2001
    Location
    Canada
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Using parameters via EXEC()?

    I've got an update script that runs 3 times a day. The one php file call others with exec():


    exec("/usr/bin/php -q home/public_html/update1.php");
    exec("/usr/bin/php -q home/public_html/update2.php");


    but if I try running one with a parameter:

    exec("/usr/bin/php -q home/public_html/update1.php?action=dodo");

    It doesn't work. I'm not too familar with UNIX command line use (or Unix at all), but I'm assuming the ? is causing problems.

    Any of you Unix gurus know a work around for this? Thanks.

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is this run through a cron job? I am just wondering why you opted for the exec() command. You can use a cron job for this and then you can just specify the command to run


    /usr/bin/php -q home/public_html/update1.php?action=dodo > /dev/null


    Try reading up on how to set up cron jobs on your server, and you should be all set.

    If you still insist on a php script try(not tested)


    EscapeShellCmd("/usr/bin/php -q home/public_html/update1.php?action=dodo");
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  3. #3
    SitePoint Enthusiast Jujubee's Avatar
    Join Date
    Mar 2001
    Location
    Canada
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, this is a CRON job, but I've got several scripts to run and adding them all to CRON is a hassle to keep track of.

    I figured I could just set one PHP file that calls others. So if I need to change the times for the updates, I'd just update the one line in CRON.

    In retrospect though, I rarely change the times, so I can't get it to work any other way, I'll do it directly as you mention. Thanks for the help.

    I'll test out the Escape command.

  4. #4
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Better yet stick them in a shell script


    Code:
    #!/bin/sh
    /usr/bin/php -q home/public_html/update1.php?action=dodo > /dev/null 
    /usr/bin/php -q home/public_html/update2.php?action=dodo > /dev/null 
    /usr/bin/php -q home/public_html/update3.php?action=dodo > /dev/null
    Please don't PM me with questions.
    Use the forums, that is what they are here for.


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
  •