Results 1 to 6 of 6

Thread: PHP Cli - How to run a page periodically?

  1. #1
    Join Date
    Aug 2009
    Location
    Pakistan
    Beans
    89
    Distro
    Ubuntu 12.04 Precise Pangolin

    Exclamation PHP Cli - How to run a page periodically?

    Hello,
    I have to run this page: http://localhost/loop/cp/feeds?d=y&u=y periodically, because it fetches the content of some feeds(RSS) and then inserts into Database and then sends SMS texts to subscribed users.

    when i run it with php-cli in bash like this: php feeds.php?u=y&d=y
    I only get:
    [4] 11719

    but nothing happens, running it like this:
    black@loopserver:/var/www/loop/cp$ php 'feeds.php?u=y&d=y'
    Could not open input file: feeds.php?u=y&d=y

    gives that ^^^

    Can any one please tell me what to do? I think the problem is coming by passing get parameters, if i just run feeds.php everything goes fine, but I need to pass in those.

    Any help would be appreciated.
    LoOp.pk - Pakistan's Art and Artists


    "A conclusion is the place where you got tired of thinking...."

  2. #2
    Join Date
    Aug 2008
    Location
    Berlin, DE
    Beans
    180
    Distro
    Kubuntu 10.04 Lucid Lynx

    Re: PHP Cli - How to run a page periodically?

    You should run it as
    Code:
    php feeds.php -u y -d y
    and then in your code you should use getopt:
    Code:
    $args = getopt("u:d:")
    $u = $args['u']
    $d = $args['d']

  3. #3
    Join Date
    Aug 2009
    Location
    Pakistan
    Beans
    89
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: PHP Cli - How to run a page periodically?

    Ah, okay, but I also want to run it through browser sometimes, means i have to use both $_GET and $args and check which one has values in it?
    no common way?
    LoOp.pk - Pakistan's Art and Artists


    "A conclusion is the place where you got tired of thinking...."

  4. #4
    Join Date
    Aug 2008
    Location
    Berlin, DE
    Beans
    180
    Distro
    Kubuntu 10.04 Lucid Lynx

    Re: PHP Cli - How to run a page periodically?

    Not that I know of.

  5. #5
    Join Date
    Aug 2009
    Location
    Pakistan
    Beans
    89
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: PHP Cli - How to run a page periodically?

    Well thanks it solved the problem
    LoOp.pk - Pakistan's Art and Artists


    "A conclusion is the place where you got tired of thinking...."

  6. #6
    Join Date
    Aug 2009
    Location
    Pakistan
    Beans
    89
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: PHP Cli - How to run a page periodically?

    One last problem is that I want to use it from web and cli both.
    But when i use this getopt() function the webbrowser doesnt let me view the page, instead downloads the php file. CLI is workign fine now, how to solve this? The code is given below:

    /
    PHP Code:
    / If get is supplied use it
    if ( isset($_GET['d']) )
        
    $dispatch $_GET['d'];
    if ( isset(
    $_GET['u']) )
        
    $update $_GET['u'];
        
    // if no values provided in get use cli args
    if ( $update != 'u' && $dispatch != 'u' )
    {
        
    //$args = getopt("u:d:");

        
    if ( isset($args['u']) )
            
    $update $args['u'];

        if ( isset(
    $args['d']) )
            
    $dispatch $args['d'];

    LoOp.pk - Pakistan's Art and Artists


    "A conclusion is the place where you got tired of thinking...."

Tags for this Thread

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
  •