Thanks for your input!
I actually really like the output of print. It makes nice tables, properly aligns things, it's great. What's so bad about using it? In my case I am actually interested in all or most of the data shown in print's output.
Also, I don't get your code examples. They don't seem to work, just like my experiments. I always get an empty string:
> :put "blah blah blah $[/system routerboard print as-value] blah blah blah"
blah blah blah
Or:
[admin@routername] /interface wireless> :global meep ("ho $[/ip address print]" . "hey")
Flags: X - disabled, I - invalid, D - dynamic
# ADDRESS NETWORK INTERFACE
0 D 192.168.1.72/24 192.168.1.0 bridgeLocal
[admin@routername] /interface wireless> :put $meep
ho hey
About the file method, that seems to work, nice! However, when used in the terminal, it seems to mess up the line endings:
[admin@routername] /interface wireless> /ip address print file=tmp
[admin@routername] /interface wireless> :put [/file get tmp contents]
# oct/ 2/2021 8:45:20 by RouterOS 6.48.4
# software id = DVR5-JWC2
#
Flags: X - disabled, I - invalid, D - dynamic
# ADDRESS NETWORK
INTERFACE
0 D 192.168.1.72/24 192.168.1.0 bridgeLocal
About the attachment approach: Good idea! That didn't even occur to me, haha. Unfortunately I can't get that to work. Sending e-mails without an attachment works fine, but as soon as I specify file=something I don't receive the e-mail. The last status reads a promising
/tool e-mail print
address: mail.smtp2go.com
port: 2525
start-tls: yes
from: routername <a.b@example.com>
user: someuser
password: nothingtoseehere
last-status: succeeded
last-address: 123.123.123.123
Just like it does when I successfully send e-mails with no attachments. Perhaps my mail server drops the mail because of the attachment and an overly enthusiastic rspamd…
Edit: Seems there was/is some greylisting involved. The first e-mails with attachments are arriving. I don't like this added level of insecurity and also the attached file doesn't get shown in-line.
Also it has this annoying header with the comments. That's also an issue when I use the file content in the body. Plus, this makes the whole neat aligned output useless because of the non fixed space font in my mail client. So, on to sending html e-mails then, I guess.
Is there really no good way of using the output of print in a script?