structure script in Mikrotik ?

Hi all, i’ve just been trying to learn scripting mikrotik, in example i want to know about after send file via email to my mail and then after the file sent from mikrotik the file will be delete automatically, i’ve been trying this way:

/tool e-mail send subject=test file=test.txt to=somebody@mail.com
/file remove test.txt

the simple code above not work even the mail not sending, what i must to do in scripting mikrotik to run the first command i want and do another command after the first command is finished and work, and for running script on scheduler how can i do that it is just use notepad on windows and save the file to .rsc and upload via ftp can it work using that way ?

Need advices please,

Thank’s a lot

you have to make sure that line of code in script executes normally as execution of script will cease at the line with the error.

Thank’s for your reply janisk, but if you don’t mind could you please explain more detail to me, cause i’m bit confused about that.
A little example will help me a lot.

I’m sorry if this thing disturb your time, thank you.

if you have script like

:log info "first log line
:obvious error
:log info "second log line"

only first command will be executed, you will get error report about second line and then script will stop.

so, when executing some complex commands, make sure you have all the arguments set for it.

Thank you janisk for your explanation, it’s very help me.

Cheer’s