I’m trying to work around a problem and haven’t yet been able to find a solution
The problem: running either ‘/export terse’ on RouterOSv6 or ‘/export terse show-sensitive’ on RouterOSv7 in order to output the configuration for backup purposes
That’s it, simple right? Maybe, but I can’t figure it out
Detecting which command based on version is doable. I’ve already posted on these forums on how to detect and run version specific commands without failure, i.e. being able to paste in a code snippet that would update wifi details regardless of whether its v6, v7, legacy or wave2 drivers.
The following code snippet will do it via the execute command. Unfortunately :execute does not provide any output to the console
# Get RouterOS Version and extract major and minor versions
:global RouterOS [:pick [/system resource get version] 0 [:find [/system resource get version] " "]]
:global RouterOSMajor [:pick $RouterOS 0]
{
:local o
:local a ([:find $RouterOS "."]+1)
:local b ([:find $RouterOS "." $a])
:if ($b > 0) do={:set $o [:pick $RouterOS 0 $b]} else={:set $o $RouterOS}
:global RouterOSMinor [:pick $o 2 [:len $o]]
}
### Version Specific Commands
:if ($RouterOSMajor > 6) do={
:global C "/export terse show-sensitive ; /log warning \"Running RouterOSv7 or above\""
} else={
:global C "/export terse ; /log warning \"Running RouterOSv6 or below\""
}
execute $C ; /system script environment remove [find where name=C]
i’ve tried outputting the execute results to a file which does work, i.e.
:execute $C file=ConfigOutput.txt
And then with v7 I can use the following to read it to the console
:put [/file get ConfigOutput.txt contents] ; /file remove ConfigOutput.txt
Great!.. but it doesn’t work on V6 it just returns an empty string…???
So i’m stumped, I can’t think of any other way to handle this without errors. At best this could be used to FTP a file to an external location but that’s not what I want. I just need the config spat out in the terminal to be seamlessly integrated with our config change software