Community discussions

MikroTik App
 
soulreaver1
just joined
Topic Author
Posts: 22
Joined: Tue May 11, 2010 12:19 pm
Location: Warsaw, Poland

Cannot get secret-download-key from script

Fri Sep 02, 2022 1:26 pm

I have a script which makes cloud backup and should send the "secret-download-key" via e-mail. Unfortunately, something is wrong. Email is being send but without the "secret-download-key". My routerboard is at RouterOS 7.5.

# config
:local email "xxxxx"
# create backup
/system backup cloud upload-file action=create-and-upload name="cloud_backup" replace="cloud_backup" password="xxxxxx";
# get info
:local date [/system/clock/get date];
:local identity [/system/identity/get name];
:local key [/system/backup/cloud/ get number=0 value-name=secret-download-key];
# send
/tool e-mail/ send from="xxxxxxx" port="587" password="xxxxx" tls=starttls to="$email" subject="$identity $date" body="$key"; 

Test scenario:
1. Run the command from terminal:
:put [/system/backup/cloud/ get number=0 value-name=secret-download-key]
It works. Returns the key.
2. Run the script. It uploads backup and sends mail but without secret-download-key.
3. Run the same command (from point 1). It doesn't work, returns nothing.
4. Open new terminal, run the same command (from point 1). It works, returns the key.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Cannot get secret-download-key from script  [SOLVED]

Fri Sep 02, 2022 2:23 pm

get number=0 (or simply get 0, is the same) do not work on scripts
the number you obtain directly with print on terminal must not be ever used, no matter if only one item is present

:put [/system/backup/cloud get [find where name="cloud_backup"] secret-download-key]
 
RafaG
just joined
Posts: 2
Joined: Fri May 24, 2019 10:08 am

Re: Cannot get secret-download-key from script

Tue Mar 05, 2024 3:07 pm

Try this:
:local cloudkey [([/system/backup/cloud/get ([ find] ->0)]->"secret-download-key") ]
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Cannot get secret-download-key from script

Tue Mar 05, 2024 4:06 pm

Try this:
Do not resurrect years old topic.

Who is online

Users browsing this forum: No registered users and 13 guests