"\$(HOSTNAME)_\$(FIRMWARE)_\$(DATE)-\$(TIME)"

I would like to name automatically my export file in the following format:
hEX_S-RB760iGS_6.48.1_20210206-193801

where:
hEX_S-RB760iGS - Hostname
_6.48.1 - Current Firmware
_20210206 - Current Date YYYYMMDD
-193801 - Current time HHMMSS

I have tried the following, but no luck:
export file=“$(HOSTNAME)$(FIRMWARE)$(DATE)-$(TIME)”

Does anyone know how to achieve this for “export file” command?

file=“$HOSTNAME_$FIRMWARE_$DATE-$TIME”

keeping in mind that all of those variables are actually defined.

Great, where do I need them to be defined? :wink:

I have set Hostname, system knows the current firmware and date/time on Mikrotik.

On my PC’s running Debian, when I backup my Firefox browser settings I execute:
tar -cvf BackUp_Firefox_$(hostname)_$(date +%Y%m%d-%H%M%S).tar -P ~/.mozilla/firefox/
so I guess, same approach does not work on MikroTik …

Executing the:
/export file=“$HOSTNAME_$FIRMWARE_$DATE-$TIME”
would result in file:
13 __-.rsc script 23.9KiB feb/08/2021 11:00:55

You can’t run bash script in ROS console. ROS uses its own scripting, more info here:
https://wiki.mikrotik.com/wiki/Manual:Scripting
https://wiki.mikrotik.com/wiki/Manual:Scripting-examples
https://wiki.mikrotik.com/wiki/Manual:Scripting_Tips_and_Tricks

You could do something like

[admin@Mikrotik] > {/system; :put "$[identity get name]_$[routerboard get current-firmware ]_$[clock get date]-$[clock get time]"; / }        
Mikrotik_7.1beta4_feb/08/2021-14:06:13

Or use

/system resource get version

instead of the installed firmware. You might also prefer

/system routerboard get serial-number

.

I used a curly brackets block to allow to “chdir” to /system, and save some typing, and then at the end “chdir” back to “/”. If you know bash, you’ll see that routeros uses

$(varname)

where bash uses

${varname}

, and

$[command]

where bash uses

$(command)



:local version [/system package update get installed-version]
:local GDate [/system clock get date]
:local Gtime [/system clock get time]
:local GDay [ :pick $GDate 4 6 ]
:local GMonth [ :pick $GDate 0 3 ]
:local GYear [ :pick $GDate 7 11 ]
:local GResult "$GDay $GMonth $GYear"
:local ExportConf ([/system identity get name])
/export compact file="$ExportConf-Version_$version-Date_$GResult-Time_$Gtime"