The MU forums have moved to WordPress.org

Running from the command line (5 posts)

  1. SteveAtty
    Member
    Posted 14 years ago #

    I've got a couple of background/query processes which extract data from my blogs, which I'd love to run without having to run them through the web. I can't use php from the command line because of the ‘header( “Location: “‘ code in wpmu-settings.php. This means that I have to use curl which still goes through apache.

    Is there any way to allow WPMU scripts to run from the php command line. I need to involve WPMU as I'm using some of the internal functions such as get_permalink.

  2. SteveAtty
    Member
    Posted 14 years ago #

    Well I sort of cludged it by copying the three config/settings files and then editing out the offending lines in wpmu-settings.php and then changing the include in the top of my php file.

    Its not ideal but it works.

    Of course super cache then complains and throws out the "page not cached message" which is a bit of pain.

  3. tdjcbe
    Member
    Posted 14 years ago #

    Will this work?

    http://www.linuxforums.org/forum/linux-programming-scripting/123603-run-php-command-line.html

    Not sure if the Location requirement will come into play. You'll probably have to include wp-blog-header.php to get at the wp functions.

    (edit: I just reread your post and I think that;s the method you;re using. Sorry if I misunderstood.)

    We actually built the scripts that we need in near empty page templates, add them to an unused theme that's only assigned to a special unused and marked as private blog, create Pages with those page templates, and then use cron jobs to call those Page urls to get the scripts to run.

    I've tried explaining that a couple of times but most folks go "huh?" so I realize it's hard to understand.

  4. SteveAtty
    Member
    Posted 14 years ago #

    That makes sense - it just seems silly if I've got something sitting on the server which is basically "interrogating" the blogs to have to go through the web server to get at them.

    The problematical lines are in wpmu-settings.php at line 166:

    if( $current_site->domain != $_SERVER[ 'HTTP_HOST' ] ) {
    
    	header( "Location: http://" . $current_site->domain . $current_site->path );
    
    		exit;
    
    	}

    W

  5. error
    Member
    Posted 14 years ago #

    If you set $_SERVER['HTTP_HOST'] yourself before loading up wp-blog-header.php then everything works fine. Set it to the vhost of the blog you want your script to operate on. (If you're using subdirectories you're on your own.)

About this Topic