Problem with fetch upload on FTP

I’m using fetch command to upload MT exported config every 5 days.
I have a script error when im trying to execute (by pasting the script in to CLI)

:delay 5;
/tool fetch address=192.168.1.1 src-path=export.rsc user=admin mode=ftp password=admin dst-path=export.rsc port=21 keep-result=no upload=yes 
:delay 10;
:delay 5;

/file remove export.rsc; 
:log info ("EXPORT COMPACT 1.5 via FTP " . ($time) . " " . ($date));

this id what i got after i paste the code:

[admin@TEST_RB] >:delay 5;
  status: finished
-- [Q quit|D dump|C-z pause]
[admin@TEST_RB] > elay 10;se]
bad command name elay (line 1 column 1)
[admin@TEST_RB] > 
[admin@TEST_RB] > /file remove export.rsc;

it seems that the problem is on the fetch command, the console returns information about successful sending and at the moment is pasted next code.
when I enter this code as a script - the exported file is not removed - so the script does not execute to the end.

on what RouterOS version is this?

Most popular in my network 5.20 5.22 5.23 and 5.24

I’m having exact the same problems. MikroTik RouterOS 6.36rc12. RouterBOARD mAP L-2nD. Can anyone help here please? Need this working…Sending supout

When you use “:delay” in the CLI without having the script in { } the delays may break the paste.
Try this:

{
    :delay 5;
    /tool fetch address=192.168.1.1 src-path=export.rsc user=admin mode=ftp password=admin dst-path=export.rsc port=21 keep-result=no upload=yes 
    :delay 10;
    :delay 5;

    /file remove export.rsc; 
    :log info ("EXPORT COMPACT 1.5 via FTP " . ($time) . " " . ($date));
}

By the way, why so many delays? Isn’t one delay enough?
My FTP backup script doesn’t even have a delay, I just delete old file right before creating the new one. That way the router also always has its configuration backup saved locally. But maybe that is a security risk?