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
Code: Select all
# 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]
Code: Select all
:execute $C file=ConfigOutput.txt
Code: Select all
:put [/file get ConfigOutput.txt contents] ; /file remove ConfigOutput.txt
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