tripal_launch_jobs.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. //
  3. // Copyright 2009 Clemson University
  4. //
  5. /*
  6. This script must be run at the base directory level of the drupal installation
  7. in order to pick up all necessary dependencies
  8. */
  9. $stdout = fopen('php://stdout', 'w');
  10. // we require one command-line argument
  11. if(sizeof($argv) < 2){
  12. print_usage($stdout);
  13. exit;
  14. }
  15. $drupal_base_url = parse_url('http://www.example.com');
  16. $_SERVER['HTTP_HOST'] = $drupal_base_url['host'];
  17. // $_SERVER['PHP_SELF'] = $drupal_base_url['path'].'/index.php';
  18. $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] = $_SERVER['PHP_SELF'];
  19. $_SERVER['REMOTE_ADDR'] = NULL;
  20. $_SERVER['REQUEST_METHOD'] = NULL;
  21. require_once 'includes/bootstrap.inc';
  22. drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
  23. fwrite($stdout, "Tripal Job Launcher\n");
  24. fwrite($stdout, "-------------------\n");
  25. // check to make sure the username is valid
  26. $username = $argv[1];
  27. if(!db_fetch_object(db_query("SELECT * FROM {users} WHERE name = '$username'"))){
  28. fwrite($stdout, "'$username' is not a valid Drupal username. exiting...\n");
  29. exit;
  30. }
  31. global $user;
  32. $user = user_load(array('name' => $username));
  33. tripal_jobs_launch();
  34. /************************************************************************
  35. *
  36. */
  37. function print_usage ($stdout){
  38. fwrite($stdout,"Usage:\n");
  39. fwrite($stdout," php ./sites/all/modules/tripal_core/tripal_launch_jobs <username> \n\n");
  40. fwrite($stdout," where <username> is a Drupal user name\n\n");
  41. }
  42. ?>