Community discussions

MikroTik App
 
lambert
Long time Member
Long time Member
Topic Author
Posts: 548
Joined: Fri Jul 23, 2010 1:09 am

/export without line wrap?

Fri Sep 16, 2011 1:53 am

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
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: /export without line wrap?

Mon Sep 19, 2011 10:24 am

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:Co ... in_options

set width reasonably high :)
 
User avatar
peterd
newbie
Posts: 46
Joined: Mon Nov 05, 2007 1:23 pm

Re: /export without line wrap?

Mon Sep 19, 2011 11:14 am

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

Regards
 
lambert
Long time Member
Long time Member
Topic Author
Posts: 548
Joined: Fri Jul 23, 2010 1:09 am

Re: /export without line wrap?

Mon Sep 19, 2011 12:32 pm

Thanks. That should work.
 
Reg24
just joined
Posts: 3
Joined: Fri Feb 03, 2017 3:45 am

Re: /export without line wrap?

Fri Feb 03, 2017 3:54 am

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:Co ... in_options

set width reasonably high :)
This doesn't work in WinBox 3.10 and 2011UiAS-2HnD fw 6.37.4

Trying to set admin+300w, then /export file=filename
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: /export without line wrap?

Fri Feb 03, 2017 10:37 am

output to the file is set to one constant line length and cannot be changed.
 
candlerb
just joined
Posts: 10
Joined: Fri Jun 30, 2017 12:07 am

Re: /export without line wrap?

Sun Sep 10, 2017 9:05 pm

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/question ... 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.
 
candlerb
just joined
Posts: 10
Joined: Fri Jun 30, 2017 12:07 am

Re: /export without line wrap?

Sun Sep 10, 2017 9:08 pm

My apologies, I did not read "output to the file". I guess file wrapping is same as login with no pseudo-tty.
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: /export without line wrap?

Tue Sep 12, 2017 11:02 am

No, output to file cannot be changed. Even with login parameters set.
 
User avatar
strods
MikroTik Support
MikroTik Support
Posts: 1623
Joined: Wed Jul 16, 2014 7:22 am
Location: Riga, Latvia

Re: /export without line wrap?

Tue Sep 12, 2017 11:45 am

You can run "/export terse" which will give output of configuration without line wraps.
 
fdaniele
just joined
Posts: 3
Joined: Sat Mar 31, 2018 8:06 am

Re: /export without line wrap?

Sat Mar 31, 2018 8:08 am

terse is perfect... thanks
 
UWtbilmC9w7jWcWAg8zB
just joined
Posts: 3
Joined: Fri Nov 23, 2018 8:03 pm

Re: /export without line wrap?

Fri Nov 23, 2018 8:06 pm

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?
 
ershov
just joined
Posts: 1
Joined: Fri Jun 09, 2023 4:29 am

Re: /export without line wrap?

Fri Jun 09, 2023 4:34 am

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.

Who is online

Users browsing this forum: No registered users and 22 guests