redef script variable from bro command line

Hi!

This is just a minor problem, but I would still like to understand, why
it does not work. I am trying to set the log rotation from the command
line. It works when I use the -e flag:

# bro -r 2009-m57.00.pcap -e "redef Log::default_rotation_interval = 20min"

It does not work, if I set the variable at the command prompt:

# bro test.bro -r 2009-m57.00.pcap rotation=20min
20.0 min
10.0 min

test.bro:

global rotation = 10min &redef;
redef Log::default_rotation_interval = rotation;

event bro_init() {
  print(rotation);
  print(Log::default_rotation_interval);
}

I suppose the reason for this is the order in which variables are initialized.

Can someone please explain?

Thanks!

Franky

Well, you're setting different things. If I change the 2nd case to
this:

    bro test.bro "Log::default_rotation_interval=20min"

... then it works as well.

In your version, when you set "rotation" it changes that global value,
but at a time when it's old value has already been assigned to
Log::default_rotation_interval. The change will not carry over, as the
assignment doesn't take place again.

Robin

> # bro -r 2009-m57.00.pcap -e "redef Log::default_rotation_interval
> = 20min" # bro test.bro -r 2009-m57.00.pcap rotation=20min

Well, you're setting different things. If I change the 2nd case to
this:

    bro test.bro "Log::default_rotation_interval=20min"

... then it works as well.

That's an even easier solution. I thought I had to use "redef".

In your version, when you set "rotation" it changes that global value,
but at a time when it's old value has already been assigned to
Log::default_rotation_interval. The change will not carry over, as the
assignment doesn't take place again.

Thank you very much! This makes things clear.

Franky

The command line assignment is essentially a "redef", just shorter for
convienience.

Robin