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: 95
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: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

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: 95
Joined: Mon May 11, 2015 8:16 pm

Re: ros_command set variable from dude

Thu May 12, 2022 11:07 pm

Thank you! :)
 
boredwitless
just joined
Posts: 6
Joined: Tue Jul 10, 2018 12:19 pm

Re: ros_command set variable from dude

Fri Aug 04, 2023 12:50 pm

The Dude code

ros_command(concatenate(":global test \"",device_property("Name"),"\""))
Is it possible to pass other information into ros_command other than from the device_property() function - I'm trying to pass [Interface.Name] into a ros_command to return the IP Address assigned to that interface.
ros_command(concatenate(":put [ip address get [find interface=",[Interface.Name]," ] address]"))

Who is online

Users browsing this forum: Majestic-12 [Bot] and 14 guests