[Bro-Dev] #583: system function with feedback

Bro Tracker bro at tracker.bro-ids.org
Thu Sep 1 10:28:48 PDT 2011


#583: system function with feedback
-----------------------------+--------------------
 Reporter:  seth             |      Owner:
     Type:  Feature Request  |     Status:  new
 Priority:  Normal           |  Milestone:  Bro1.7
Component:  Bro              |    Version:
 Keywords:  language         |
-----------------------------+--------------------
 Jon and I just came up with a proposal for talking to external processes
 and getting results.  Our idea is to center it around running the external
 process in the background as it's done now then redirecting stdin and
 stdout to temporary files and to have a file handle where the exit code
 will be available.  Bro could poll using timers for the exit code to
 indicate the external process has completed then an event would be
 generated.  Here is an example of using this function/event combination:

 {{{
 global called_procs: table[string] of string = {};

 # These are the prototypes for the function and event that need to be
 added
 # to the core.  The names are both terrible.
 global piped_exec_with_result: function(uid: string, program: string,
 to_write: string);
 global system_result: event(uid: string, exit_code: int, stdout: string,
 stderr: string);

 event bro_init()
         {
         local uid = unique_id("");
         called_procs[uid] = "date";
         piped_exec_with_result(uid, "date", "");
         }

 event system_result(uid: string, exit_code: int, stdout: string, stderr:
 string)
         {
         print fmt("The command line %s was run and exited with %d.",
 called_procs[uid], exit_code);
         print fmt("    On stdout: %s", stdout);
         print fmt("    On stderr: %s", stderr);
         }
 }}}

-- 
Ticket URL: <http://tracker.bro-ids.org/bro/ticket/583>
Bro Tracker <http://tracker.bro-ids.org/bro>
Bro Issue Tracker



More information about the bro-dev mailing list