X-Git-Url: http://git.annexia.org/?p=whenjobs.git;a=blobdiff_plain;f=tools%2Fwhenjobs.ml;fp=tools%2Fwhenjobs.ml;h=be38f670348f0a62f748af23984f1403bfedf7cf;hp=c792e266558f68d228ee5a43cbcd8718eb924ae8;hb=03b83c1a4bab53d8914c6946ad892bca30df09d0;hpb=82c14058a0252e953cae3bd2f1fc3fe00746d173 diff --git a/tools/whenjobs.ml b/tools/whenjobs.ml index c792e26..be38f67 100644 --- a/tools/whenjobs.ml +++ b/tools/whenjobs.ml @@ -95,6 +95,7 @@ let rec main () = "--lib", Arg.Set_string libdir, "dir Specify directory that contains pa_when.cmo"; "--set", Arg.Unit (set_mode `Set), " Set the variable"; "--start", Arg.Unit (set_mode `Start), "name Start a job manually"; + "--tail", Arg.Unit (set_mode `Tail), "serial Tail job output"; "--type", Arg.Set_string typ, "bool|int|float|string|unit Set the variable type"; "--upload", Arg.Unit (set_mode `Upload), " Upload the script"; "--variables", Arg.Unit (set_mode `Variables), " Display all variables and values"; @@ -220,6 +221,14 @@ Options: ); start_job (List.hd args) + | Some `Tail -> + if List.length args != 1 then ( + eprintf "whenjobs --tail serial\n"; + suggest_help (); + exit 1 + ); + tail (List.hd args) + and edit_file () = (* If there is no initial file, create an empty one containing the * tutorial. @@ -421,6 +430,19 @@ and start_job name = ); stop_client client + (* This only works for local. If we ever make whenjobs work + * remotely we'll have to change the implementation to use + * the server. + *) +and tail serial = + let client = start_client () in + let job = Whenproto_clnt.When.V1.get_job client serial in + stop_client client; + let cmd = + sprintf "tail -f %s/output.txt" + (Filename.quote job.Whenproto_aux.job_tmpdir) in + exit (Sys.command cmd) + and unused_error args op = if args <> [] then ( eprintf "whenjobs %s: unused parameters on the command line.\n" op;