Hello fellow tikers,
is there any “straight” way to save command output (/ping count=x for example) to variable for parsing it later? :execute … file= is good but is not very straightforward ![]()
TIA, regards,
Konstantin
Hello fellow tikers,
is there any “straight” way to save command output (/ping count=x for example) to variable for parsing it later? :execute … file= is good but is not very straightforward ![]()
TIA, regards,
Konstantin
I’m not certain whether you want to save the output to disk or just put it in variable, but if it is the later case, you can do something like this:
global a [:ping address=google.com count=5 as-value ]
Which stores the output for each separate ping in an array, a, that you can work on.
Not my case exactly as I need final results, but thank you anyway, that’s a nice tip!
:local dohServers {cloudflare=1.1.1.1; google=8.8.8.8; quad9=9.9.9.9};
:put $dohServers;
:foreach k,v in=$dohServers do={
:local pingResult [:tostr [/tool ping address=$v count=1 as-value]];
:execute ":global $k \"$pingResult\"";
:put "Global variable: $k \"$pingResult\"";
};
cloudflare=1.1.1.1;google=8.8.8.8;quad9=9.9.9.9
Global variable: cloudflare “.id=*0;host=1.1.1.1;seq=0;size=56;time=00:00:00.014520;ttl=60”
Global variable: google “.id=*0;host=8.8.8.8;seq=0;size=56;time=00:00:00.014955;ttl=119”
Global variable: quad9 “.id=*0;host=9.9.9.9;seq=0;size=56;time=00:00:00.013914;ttl=59”