Pass in a dynamic list of files to /tool e-mail send

I’m attempting to send an email from RouterOS 7.20 containing a list of files. If I hard-code the list of files, it works perfectly:

/tool e-mail send to=”my.email.address@mydomain.mytld” \
    subject=”test email” body=”See attached list of files” \
    file=myrouter-file1,myrouter-file2,myrouter-file3…

However, I need the list of files to be dynamically generated.

This doesn’t work:

/tool e-mail send to=”my.email.address@mydomain.mytld” \
    subject=”test email” body=”See attached list of files” \
    file="$[/system identity get name]-file1","$[/system identity get name]-file2","$[/system identity get name]-file3"

input does not match any value of file

I’ve tried passing the list of files via an array, like this:

:global files {"$[/system identity get name]-file1","$[/system identity get name]-file2","$[/system identity get name]-file3"}
/tool e-mail send to=”my.email.address@mydomain.mytld” \
    subject=”test email” body=”See attached list of files” file="$files"

I’ve tried without enclosing the array name in quotes, like this:

/tool e-mail send to=”my.email.address@mydomain.mytld” \
    subject=”test email” body=”See attached list of files” file=$files

Nothing I try works.

As a programmer I feel I should be able to understand how to do this, but everything I’ve tried simply results in the input does not match any value of file error.

Can someone point me in the right direction?

This is something for rextended, Amm0, optio and many experts that I'm not tagging, but I would try with :for each X in…

I appreciate the reply, however I want to send a single email, not an email for each file.

Did you try

file=("$[/system identity get name]-file1","$[/system identity get name]-file2","$[/system identity get name]-file3")

?

Put parentheses around your 1st attempt.

1 Like

:star_struck: that is awesome. Thank you!

are not the same as "

:local toadd "my.email.address@mydomain.mytld"
:local subj  "test email"
:local mbody "See attached list of files"
:local sid   [/system identity get name] 
/tool e-mail send to=$toadd subject=$subj body=$mbody file=("$sid-file1","$sid-file2","$sid-file3")

Of course, the device identity name must not contain characters that are not valid as a file name...

1 Like

I like how much more elegant the use of variables is for this; thanks for that.

What point are you making in the opening sentence where you say close quotes are not the same as quotes? It seems like you may as well have said apples are not the same as oranges, unless I'm missing something subtle?

He means that two beds are not one twinbed :slight_smile: :slight_smile:

image

One " vs two ''.

“ - Left/opening double (smart) quotation mark

” - Right/closing double (smart) quotation mark

″ - Double-prime, inches or seconds

" - Typewriter-style double (dumb) quotation mark

‘‘ - 2x Left/opening single (smart) quotation mark

’’ - 2x Apostrophe or right/closing single (smart) quotation mark

′′ - 2x Prime, feet or minutes

'' - 2x Typewriter-style apostrophe or single (dumb) quotation mark

Can look same but they are all different characters.

(I don't understand this way of saying, better "apples are not pears" or "lemons are not oranges", but that's another story...)

Your post use the wrong quotation marks in the scripts...

are invalid, must be used "

writing to=”my.email.address@mydomain.mytld” is like write to="”my.email.address@mydomain.mytld”"

That is so curious. I think that must be due to wysiwyg editor here converting the quotes - I definitely don't have them that way in my actual scripts. I started out writing the question using the "rich text editor" option in the toolbar, but then switched it to the standard markdown editor because that mode is much easier to use.

As a test, I wrote the below sentences using the regular "quote" key on my keyboard, just switching between editor modes:

This bit was written using the “rich text editor”.

This bit was written using the "standard markdown editor".

For a technical site it would likely be better if the editor didn't make those assumptions, and just entered the actual letters typed into the editor, regardless of whether it is in "rich text" mode or not.

Old fashioned forum engine (phpBB) is more simple but does not many things behind the scenes.
Current forum engine is newer/popular/nice/modern/convinient/etc. and tries to do a lot things helping out. Sometimes that help goes past golden meana as the engine tries to be "too clever".

1 Like