Community discussions

MUM Europe 2020
 
1001001
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 70
Joined: Mon Sep 24, 2012 12:46 pm

Creating rsc file with identity/date/time

Fri Jul 28, 2017 1:41 pm

Hi,

I'm currently trying to export all secrets in /ppp secret into a file with $identity$date$time as name.
The code is as follows
:global date ([:pick [/system clock get date] 0 12]);
:global time ([:pick [/system clock get time] 0 9]);
:local fileName (.[system identity get name]"$date""$time")
:local rsc $fileName
/ppp secret export file=$rsc;
But it only outputs files with the time as name. :/
Can anyone tell me why it would do so?
THX
 
User avatar
strods
MikroTik Support
MikroTik Support
Posts: 1424
Joined: Wed Jul 16, 2014 7:22 am
Location: Riga, Latvia

Re: Creating rsc file with identity/date/time

Fri Jul 28, 2017 2:06 pm

Try this:
:local fileName ([system identity get name] . "_". [:pick [/system clock get date] 0 12] . "_". [:pick [/system clock get time] 0 9] . ".rsc")
/ppp secret export file=$rsc;
 
pe1chl
Forum Guru
Forum Guru
Posts: 6227
Joined: Mon Jun 08, 2015 12:09 pm

Re: Creating rsc file with identity/date/time

Fri Jul 28, 2017 2:07 pm

The problem is that the date contains slashes ('/') and this is an invalid character in a filename because it is the directory-filename separator.
So you must do more picking to get only the variable data and not the separator characters from the date.
 
1001001
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 70
Joined: Mon Sep 24, 2012 12:46 pm

Re: Creating rsc file with identity/date/time

Fri Jul 28, 2017 2:23 pm

Thank you for your hints, now it works.
:global date ([:pick [/system clock get date] 0 3] . [:pick [/system clock get date] 4 6] . [:pick [/system clock get date] 7 11]);
:global time ([:pick [/system clock get time] 0 9]);
:local fileName ([/system identity get name]."_".$date."_".$time.".rsc")
:local rsc $fileName

Who is online

Users browsing this forum: No registered users and 20 guests