[Bro] External commands - Error
Riccardo Bortolameotti
r.bortolameotti at gmail.com
Wed Apr 23 03:03:05 PDT 2014
Sorry for writing another email.
This is a simple script that does not work, and basically follows the
same concept.
@load base/utils/exec
event bro_init()
{
local cmd = Exec::Command($cmd="echo 'hello'");
when (local res = Exec::run(cmd))
{
print "hello";
print res$stdout;
}
}
On Wed, 2014-04-23 at 12:00 +0200, Riccardo Bortolameotti wrote:
> Hi guys,
>
> I have inserted the command within the when statement
> {
> local s = "whatever";
> local anagram : Exec::Command;
> local param = "-l /home/riccardo/ngram-ids/ngram-ids/save -m test -t 0
> -U " + s;
> local prog = "/home/riccardo/ngram-ids/ngram-ids/ngram-ids" + param;
> anagram = [$cmd = prog];
> when ( local res = Exec::run(anagram) )
> {
> print "I AM IN! - Debug";
> }
>
> return "Not Executed!";
> }
>
> However seems it is not able to enter in the block. Like the program is
> not executed at all. If I run the command from my command line it
> perfectly works. I do not really understand why it does not go within
> that block.
>
> thank you for help,
>
> R.
>
> On Wed, 2014-04-16 at 10:04 -0700, Bernhard Amann wrote:
> > Hi,
> >
> > you have to use Exec::run inside of a when statement - because the command is run asynchronously results are not immediately available.
> >
> > You can e.g. see https://github.com/bro/bro/blob/master/scripts/base/utils/dir.bro for an example that uses it.
> >
> > Bernhard
> >
> > On Apr 16, 2014, at 8:03 AM, Riccardo Bortolameotti <r.bortolameotti at gmail.com> wrote:
> >
> > >
> > > Hello everybody,
> > >
> > > I am having a problem regarding external command execution.
> > >
> > > This is the piece of code:
> > > function f (s : string) : Exec::Result
> > > {
> > > local anagram : Exec::Command;
> > > local res : Exec::Result;
> > > res = [$exit_code = 0];
> > > local prog = "/home/riccardo/ngram-ids/ngram-ids/ngram-ids";
> > > local param = "-l /home/riccardo/ngram-ids/ngram-ids/save -m test -t 0 -U " + s;
> > > anagram = [$cmd = prog, $stdin = param];
> > > res = Exec::run(anagram);
> > > return res;
> > > }
> > > Basically the problem is that the variable res do not receive any value
> > > from the execution of the program. Since this execution should be run
> > > several times because is within a loop, I do not know if there are
> > > problems of threading (like wait for the result). I also receive an
> > > error like this:
> > >
> > > 1394205441.982764 warning: non-void function returns without a value:
> > > Exec::run
> > > 1394205441.982764 error: return trigger in context which does not allow
> > > delaying result
> > >
> > > thank you in advance,
> > >
> > > R.
> > >
> > > _______________________________________________
> > > Bro mailing list
> > > bro at bro-ids.org
> > > http://mailman.ICSI.Berkeley.EDU/mailman/listinfo/bro
> > >
> > >
> >
>
More information about the Bro
mailing list