Tripal v1.0 (6.x-1.0)
tripal_launch_jobs.php
Go to the documentation of this file.
00001 <?php
00002 
00011 $stdout = fopen('php://stdout', 'w');
00012 
00013 // we require one command-line argument
00014 if (sizeof($argv) < 2) {
00015   print_usage($stdout);
00016   exit;
00017 }
00018 
00019 $drupal_base_url = parse_url('http://www.example.com');
00020 $_SERVER['HTTP_HOST'] = $drupal_base_url['host'];
00021 //  $_SERVER['PHP_SELF'] = $drupal_base_url['path'].'/index.php';
00022 $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] = $_SERVER['PHP_SELF'];
00023 $_SERVER['REMOTE_ADDR'] = NULL;
00024 $_SERVER['REQUEST_METHOD'] = NULL;
00025 
00026 require_once 'includes/bootstrap.inc';
00027 drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
00028 
00029 // check to make sure the username is valid
00030 $username = $argv[1];
00031 $do_parallel = $argv[2];
00032 if (!db_fetch_object(db_query("SELECT * FROM {users} WHERE name = '%s'", $username))) {
00033   fwrite($stdout, "'$username' is not a valid Drupal username. exiting...\n");
00034   exit;
00035 }
00036 
00037 global $user;
00038 $user = user_load(array('name' => $username));
00039 
00040 
00041 fwrite($stdout, "Tripal Job Launcher\n");
00042 fwrite($stdout, "Running as user ' . $username . '\n");
00043 fwrite($stdout, "-------------------\n");
00044 
00045 tripal_jobs_launch($do_parallel);
00046 
00052 function print_usage($stdout) {
00053   fwrite($stdout, "Usage:\n");
00054   fwrite($stdout, "  php ./sites/all/modules/tripal_core/tripal_launch_jobs <username> \n\n");
00055   fwrite($stdout, "    where <username> is a Drupal user name\n\n");
00056 }
 All Classes Files Functions Variables