Community discussions

MikroTik App
 
User avatar
own3r1138
Long time Member
Long time Member
Topic Author
Posts: 681
Joined: Sun Feb 14, 2021 12:33 am
Location: Pleiades
Contact:

value=[/system resource get date]

Mon May 16, 2022 4:02 pm

Hi,
Whenever I use "get date" as the name-value parameter my script won't work correctly "script error: invalid filename", without "date" it would run fine.
Terminal check
] > :local date [/system clock get date]; put $date;
] > may/16/2022
Script
:log info "backup beginning now"
:global name=backupfile value=([/system identity get name] ."-". [/system resource get uptime] . "-" . [/system clock get time].".backup")
/system backup save name=$backupfile
:log info "backup pausing for 10s"
:delay 10s
:log info "backup being uploaded"
/tool fetch address=aa.bb.cc.dd src-path=$backupfile user=username@local.lan mode=ftp password="securepassword" dst-path="/$backupfile" upload=yes;
:log info "backup finished"
:delay 20s
:log info "Deleting Backup File"
/file remove $backupfile;
:log info "Deleting Backupfile File"
2022-05-16_17-16-21.png
2022-05-16_17-19-51.png
You do not have the required permissions to view the files attached to this post.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: value=[/system resource get date]

Mon May 16, 2022 4:06 pm

[...]
:global backupfile "$[/system identity get name]-$[/system resource get uptime]-$[/system clock get time].backup"
[...]
 
User avatar
own3r1138
Long time Member
Long time Member
Topic Author
Posts: 681
Joined: Sun Feb 14, 2021 12:33 am
Location: Pleiades
Contact:

Re: value=[/system resource get date]

Mon May 16, 2022 4:11 pm

Hi,
Thank you, but as soon as I use "date" it will break the script.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: value=[/system resource get date]  [SOLVED]

Mon May 16, 2022 4:12 pm

Doesn't the / character in the date look like anything you've seen before?...

Hint:
disk1/directory1/directory2/filename.ext

[...]
:global arrMonths {jan="01";feb="02";mar="03";apr="04";may="05";jun="06";jul="07";aug="08";sep="09";oct="10";nov="11";dec="12"}
:global today [/system clock get date]
:global dateinside "$[:pick $today 7 11]-$($arrMonths->[:pick $today 0 3])-$[:pick $today 4 6]"
:global backupfile "$[/system identity get name]_$dateinside_$[/system clock get time]_$[/system resource get uptime].backup"
/system backup save name=$backupfile
[...]

On scripts convert all :global to :local variables.
 
User avatar
own3r1138
Long time Member
Long time Member
Topic Author
Posts: 681
Joined: Sun Feb 14, 2021 12:33 am
Location: Pleiades
Contact:

Re: value=[/system resource get date]

Mon May 16, 2022 4:30 pm

shot me in the head. Honestly, I don't like scripting I think it goes both ways :d
Thank you all good.

Anyway, I'm looking for someone who could do a project using UM, API, and PHP for accounting is this something that interests you?
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: value=[/system resource get date]

Mon May 16, 2022 4:33 pm

Ahhh... too much... :)
I do not know API or PHP :roll:
 
User avatar
own3r1138
Long time Member
Long time Member
Topic Author
Posts: 681
Joined: Sun Feb 14, 2021 12:33 am
Location: Pleiades
Contact:

Re: value=[/system resource get date]

Mon May 16, 2022 4:36 pm

I see, Thank you.
<3

Who is online

Users browsing this forum: rogerioqueiroz and 26 guests