Community discussions

MikroTik App
 
PolPin
just joined
Topic Author
Posts: 1
Joined: Thu Feb 03, 2022 12:53 pm

ros_command set variable from dude

Thu Feb 03, 2022 1:02 pm

Hi,

I have a question for you, is it possible to send a variable, eg [Device.CustomField2] in ros_command.
I want to write a universal function that will retrieve the appropriate parameter

ros_command(":local clientIP [Device.CustomField2]; :local peer; :local ph2; :foreach line in=[/ip ipsec policy print as-value where disabled=no and template!=yes and sa-dst-address=$clientIP] do={:foreach name,item in=$line do={if ($name=\"peer\") do= {:set peer $item}; if ($name=\"ph2-count\") do= {:set ph2 \"\"; if ($item=0) do={:set ph2 \"DOWN\"}; if ($item>0) do={:set ph2 \"UP\"};}; }; :put ($peer.\" \".$ph2)}")
 
excession
Frequent Visitor
Frequent Visitor
Posts: 91
Joined: Mon May 11, 2015 8:16 pm

Re: ros_command set variable from dude

Wed May 04, 2022 12:09 pm

+1 I'm also curious if there's a syntax that will make this work.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 9596
Joined: Tue Feb 25, 2014 12:49 pm
Location: 🇮🇹, my 💔 is in 🇺🇦

Re: ros_command set variable from dude  [SOLVED]

Wed May 04, 2022 1:18 pm

The Dude code

ros_command(concatenate(":global test \"",device_property("Name"),"\""))
 
excession
Frequent Visitor
Frequent Visitor
Posts: 91
Joined: Mon May 11, 2015 8:16 pm

Re: ros_command set variable from dude

Thu May 12, 2022 11:07 pm

Thank you! :)

Who is online

Users browsing this forum: No registered users and 0 guests