Share vector

Hi,

I would like to access to the same vector and modificate it in two different scripts, How can I do this?

Regards

Hi

I guess you can put that vector in one script, and call it from the second script using the first script module name :

script 1 :

module S1;

export {
global vec: vector of string;
};

Hi

I would like to do something like this

script 1 :

module S1;

export {
global vec: vector of string;
};

event bro_init() {

vec[0] = “hello”

}

And script2 can print vec

So, have you tried it? :slight_smile: Two things to consider: 1) event &priority and 2) If you’re running Bro in standalone vs cluster mode.

Correcting a couple syntax issues and adding a priority:

Script1:
module S1;

export {
global vec: vector of string;
}

event bro_init() &priority=1 {
vec[0] = “hello”;
}

Script2:
module S2;

event bro_init()
{
print S1::vec;
}

$ /usr/local/bro/bin/bro -i en0 script1.bro script2.bro
listening on en0

[hello]

It gets more complicated if you’re running in a cluster.

-Dop