script works in terminal windwo but not in scheduler

Hello,
I tried to download the backup file in cloud and if I open a new terminal and write below, it works fine.

[brg3466@CCR1009] > {
{... #get backup file download key
{... :local key [/system backup cloud get number=0 secret-download-key];
{...                                                                    
{... # get cloud backup file
{... /system backup cloud download-file action=download secret-download-key="$key";
{... }                                                                             
  status: finished

But if put the above in script , it doesn’t work. Anyone knows why ?

get number=0 will not work,
read this:
http://forum.mikrotik.com/t/read-before-creating-yet-another-new-my-script-does-not-work-topic/122693/1

Use this:

  # we are not interested in output, but print is
  # required to fetch information from cloud
  / system backup cloud print as-value;
  
  / system backup cloud upload-file action=create-and-upload password=$BackupPassword replace=[ get ([ find ]->0) name ];

If you want this to be fully automated and with notifications have a look at my script cloud-backup.

@mrz, @eworm, thank you both for the tips. I read mrz’s thread and realized that console number doesn’t work. It is a very informative thread ! I wish I could have read it earlier. :slight_smile:
A long way to go for good scripting !