/export without line wrap?

Searching for ways to do things without “x” never works well.

I want to export items from my MikroTiks but I want to avoid having to put the continued lines back together with my scripts. I can add a subroutine to my scripts to do that for me, but it would be nice if there were an option in RouterOS which would avoid putting them in there in the first place.

If I connect with a terminal, I get lines wrapped as wide as the terminal.

If I “ssh router ‘/export;’ > router.export.txt” I get lines wrapped for an 80 column terminal. I would hope for no wrapping when not in an active terminal.

With “ssh router -t ‘/export;’ > router.export.txt” I get terminal width line (100 columns in this case, not wide enough for the lines I need) but I also get the escape codes which color the output.

add address=CPEPriv address-list=8MbDedicated client-id=1:0:0:0:0:0:0 \
    comment=customer1-cpe disabled=no mac-address=00:00:00:00:00:00 \
    server=ap_dhcp1

should be:

add address=CPEPriv address-list=8MbDedicated client-id=1:0:0:0:0:0:0 comment=customer1-cpe disabled=no mac-address=00:00:00:00:00:00 server=ap_dhcp1

there is no way to set it in export as that gets tailored for terminal you are using. On the other hand you can try to use login options that set some auto-detected values for the terminal session.
http://wiki.mikrotik.com/wiki/Manual:Console_login_process#Console_login_options

set width reasonably high :slight_smile:

It would be nice if you could do that from winbox, as an option to set permanently

Regards

Thanks. That should work.

This doesn’t work in WinBox 3.10 and 2011UiAS-2HnD fw 6.37.4

Trying to set admin+300w, then /export file=filename

output to the file is set to one constant line length and cannot be changed.

That’s not the case: if you’ve connected from Linux over ssh, and you drag the window narrower or wider and re-run /export, the line breaks are in a different place to match the new width.

The mechanism is described here: https://unix.stackexchange.com/questions/207782/how-are-terminal-length-and-width-forwarded-over-ssh-and-telnet

You can see the difference by setting a wide window and then comparing:

ssh -t admin@gw '/export'   # no pty, uses default line width
ssh -T admin@gw '/export'   # with pty, adjusts to line width of window

It certainly would be very nice to be able to say “don’t wrap”; having variable wrapping makes it difficult to compare diffs.

My apologies, I did not read “output to the file”. I guess file wrapping is same as login with no pseudo-tty.

No, output to file cannot be changed. Even with login parameters set.

You can run “/export terse” which will give output of configuration without line wraps.

terse is perfect… thanks

Hi @strods when running an export with the terse option I get:

[admin@c0re] > /export terse
expected end of command (line 1 column 9)

On our other 3 routers it is working as expected. What is wrong with this one?

Hey I just use this for the purpose of joining broken lines:

ssh 192.168.88.1 /export | perl -npE 's/^\s++// if $ll; $ll = s/\\[\r\n]*$//;'

(replace 192.168.88.1 with your Mikrotik’s address)

‘terse’ option doesn’t quite solve the issue since it also changes the output format.

Can I ask why?
If it’s there for compatibility, can’t we at least have an option to override it?