#! /usr/bin/env php project = PROJECT; $req->authenticator = get_auth(); $req->app_name = APP_NAME; $req->batch_name = "foobar"; $f->source = $argv[2]; $job->input_files = array($f); $job->rsc_fpops_est = 1e12; $job->command_line = ""; $req->jobs[] = $job; list($id, $errmsg) = boinc_submit_batch($req); if ($errmsg) { echo "Error: $errmsg\n"; } else { echo "batch ID: $id\n"; } } function handle_query() { $req->project = PROJECT; $req->authenticator = get_auth(); list($batches, $errmsg) = boinc_query_batches($req); if ($errmsg) { echo "Error: $errmsg\n"; return; } foreach ($batches as $batch) { echo "batch $batch->id: "; switch ($batch->state) { case 1: echo "In progress"; break; case 2: echo "Completed"; break; case 3: echo "Aborted"; break; case 4: echo "Retired"; break; } } } function handle_get_output() { global $argc, $argv; if ($argc != 3) usage(); $req->project = PROJECT; $req->authenticator = get_auth(); $req->batch_id = $argv[2]; $url = boinc_get_output_files($req); echo "Zipped output files are at $url\n"; } function handle_abort() { global $argc, $argv; if ($argc != 3) usage(); $req->project = PROJECT; $req->authenticator = get_auth(); $req->batch_id = $argv[2]; $errmsg = boinc_abort_batch($req); if ($errmsg) { echo "Error: $errmsg\n"; } else { echo "Batch aborted\n"; } } function handle_retire() { global $argc, $argv; if ($argc != 3) usage(); $req->project = PROJECT; $req->authenticator = get_auth(); $req->batch_id = $argv[2]; $errmsg = boinc_retire_batch($req); if ($errmsg) { echo "Error: $errmsg\n"; } else { echo "Batch retired\n"; } } if ($argc < 2) usage(); switch ($argv[1]) { case "submit": handle_submit(); break; case "query": handle_query(); break; case "get_output": handle_get_output(); break; case "abort": handle_abort(); break; case "retire": handle_retire(); break; default: usage(); } ?>