Cannot get secret-download-key from script

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.

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]

Try this:

:local cloudkey [([/system/backup/cloud/get ([ find] ->0)]->"secret-download-key") ]

Do not resurrect years old topic.