Community discussions

MikroTik App
 
Josephny
Member
Member
Topic Author
Posts: 495
Joined: Tue Sep 20, 2022 12:11 am

Script not working

Sun Apr 07, 2024 6:47 pm

I just cannot get this to work.

identify of MT device is: 125-hAP

The script creates the file:

_125-hAP_2024-04-07_.txt

Including the underline characters at the beginning and end of the file

But the fetch command cannot find the file.

/system
:local cdate [clock get date] 
:local yyyy  [:pick $cdate 0  4]
:local MM    [:pick $cdate 5  7]
:local dd    [:pick $cdate 8 10]
:local identitydate "$[identity get name]_$yyyy-$MM-$dd"

/ip/address print file="[$identitydate]"

 /tool fetch upload=yes mode=ftp ascii=no src-path="[$identitydate].txt" dst-path="/mikrotik-backups/$[$identitydate].txt" address=192.168.2.22 port=21 user=mikrotik password=mikrotik

/file remove "[$identitydate]"
Also tried the /tool fetch command with src-path="$[$identitydate].txt"

As well as without the .txt

Did something change in the scripting over the past several RouterOS updates?

Thanks!
 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 3548
Joined: Sun May 01, 2016 7:12 pm
Location: California

Re: Script not working

Sun Apr 07, 2024 7:09 pm

There were some recent builds that "sanitized" the file names. In latest 7.15beta9, it returns to the "old" behavior.
*) console - added "sanitize-names" property under "/console/settings" menu (option for replacing reserved characters with underscores for files, disabled by default);
 
Josephny
Member
Member
Topic Author
Posts: 495
Joined: Tue Sep 20, 2022 12:11 am

Re: Script not working

Sun Apr 07, 2024 8:11 pm

I don't know what sanitize means in this context?

I'm sure there was no version that would have given be a health problem (except maybe psychological problems).
 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 3548
Joined: Sun May 01, 2016 7:12 pm
Location: California

Re: Script not working

Sun Apr 07, 2024 8:16 pm

Specifically, v7.13 and v7.14 have this changes:
*) console - replace reserved characters in file and script names with underscores;
So sanitize means remove spaces and special characters. The reverted this as a default in 7.15 beta.
 
Josephny
Member
Member
Topic Author
Posts: 495
Joined: Tue Sep 20, 2022 12:11 am

Re: Script not working

Sun Apr 07, 2024 8:26 pm

*) console - replace reserved characters in file and script names with underscores;
Wow, as if the proper usage of "$" and "[" weren't complicated enough in filenames/variable-names.
 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 3548
Joined: Sun May 01, 2016 7:12 pm
Location: California

Re: Script not working

Sun Apr 07, 2024 8:36 pm

And changing things in different versions really does add even more complexity. That's why they reverted recently I suspect.

Who is online

Users browsing this forum: No registered users and 11 guests