Community discussions

MikroTik App
 
User avatar
ScottReed
Member Candidate
Member Candidate
Topic Author
Posts: 114
Joined: Thu Sep 24, 2009 9:47 pm
Location: Montana / Western Massachusetts

"print" to file truncating results at 80 columns

Fri May 15, 2015 10:51 pm

When running this...
/ip dhcp-server lease print file=dhcp_leases where ! dynamic and status="bound"
The resulting file truncates the output and abruptly ends at column 80.

I have tried via SSH with increased column width. Tried via Winbox terminal. Same results.

If I run the command at the console directly like this...
/ip dhcp-server lease print where ! dynamic and status="bound"
The output is clean and I can copy/paste to my editor.

Anyone know how to get "print" to not truncate at 80 columns? Would be nice because I need to run this command at 35 routers and would like to take a lot of the manual copy/pasting out of the equation! :D
 
scriptinfu
just joined
Posts: 4
Joined: Tue Feb 02, 2016 3:00 pm

Re: "print" to file truncating results at 80 columns

Tue Feb 02, 2016 3:13 pm

I was wondering if you ever found a solution to this bug?
 
scriptinfu
just joined
Posts: 4
Joined: Tue Feb 02, 2016 3:00 pm

Re: "print" to file truncating results at 80 columns

Tue Feb 02, 2016 3:17 pm

When running this...
/ip dhcp-server lease print file=dhcp_leases where ! dynamic and status="bound"
The resulting file truncates the output and abruptly ends at column 80.

I have tried via SSH with increased column width. Tried via Winbox terminal. Same results.

If I run the command at the console directly like this...
/ip dhcp-server lease print where ! dynamic and status="bound"
The output is clean and I can copy/paste to my editor.

Anyone know how to get "print" to not truncate at 80 columns? Would be nice because I need to run this command at 35 routers and would like to take a lot of the manual copy/pasting out of the equation! :D
Has this been resolved?
 
User avatar
ScottReed
Member Candidate
Member Candidate
Topic Author
Posts: 114
Joined: Thu Sep 24, 2009 9:47 pm
Location: Montana / Western Massachusetts

Re: "print" to file truncating results at 80 columns

Thu Feb 04, 2016 3:18 pm

No.
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7052
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: "print" to file truncating results at 80 columns

Thu Feb 04, 2016 4:11 pm

I assume that you are worried that some of the fields are not visible.?

'print details' outputs all parameters and doe snot truncate anything.
 
User avatar
ScottReed
Member Candidate
Member Candidate
Topic Author
Posts: 114
Joined: Thu Sep 24, 2009 9:47 pm
Location: Montana / Western Massachusetts

Re: "print" to file truncating results at 80 columns

Thu Feb 04, 2016 4:19 pm

I assume that you are worried that some of the fields are not visible.?

'print details' outputs all parameters and doe snot truncate anything.
First, thank you for your reply. It is much appreciated. Unfortunately, that is not the desirable output for this particular case. While 'print detail' does indeed show all the details, it is not in delimited columns for easy copy/paste.

The ultimate goal here is to open the output in Notepad++ (or similar) and then Alt-Select a column and copy for use elsewhere. But when the output is truncated at column 80 it is not very useful.

But, I guess you could run in the terminal:
 /ip dhcp-server lease print without-paging where ! dynamic and status="bound" 
...and then just right-click and Copy All.

That works fine.
 
scriptinfu
just joined
Posts: 4
Joined: Tue Feb 02, 2016 3:00 pm

Re: "print" to file truncating results at 80 columns

Thu Feb 04, 2016 7:08 pm

Hey thanks for the reply! I am still having issues. Here is the output when I use ssh to print:

ssh router.ip /ip dhcp-server lease print without-paging
Flags: X - disabled, R - radius, D - dynamic, B - blocked
# ADDRESS MAC-ADDRESS HO SER.. RA
0 D 255.255.255.255 00:00:00:00:00:00 def..

You can see the information is not correct HO SER.. RA def.. it would be great to get the output the same as when actually logged in. Say if I wanted to print all leases for that moment to a text file using ssh how is the information provided useful?
 
scriptinfu
just joined
Posts: 4
Joined: Tue Feb 02, 2016 3:00 pm

Re: "print" to file truncating results at 80 columns

Thu Feb 04, 2016 7:19 pm

mrz,

It seems your solution works. Thank you.
 
changeip
Forum Guru
Forum Guru
Posts: 3830
Joined: Fri May 28, 2004 5:22 pm

Re: "print" to file truncating results at 80 columns

Sat Feb 06, 2016 6:00 am

This is what you need - very nice feature really.

http://wiki.mikrotik.com/wiki/Manual:Co ... in_process

Just use "admin+120w" as the username instead of "admin".

Sam
 
User avatar
ScottReed
Member Candidate
Member Candidate
Topic Author
Posts: 114
Joined: Thu Sep 24, 2009 9:47 pm
Location: Montana / Western Massachusetts

Re: "print" to file truncating results at 80 columns

Mon Feb 08, 2016 4:04 pm

This is what you need - very nice feature really.

http://wiki.mikrotik.com/wiki/Manual:Co ... in_process

Just use "admin+120w" as the username instead of "admin".

Sam
Thank you, but as stated in my OP, I already tried increasing the terminal width.

It does not fix the issue with "print" truncating at 80w when outputting to a file.
 
User avatar
normis
MikroTik Support
MikroTik Support
Posts: 26368
Joined: Fri May 28, 2004 11:04 am
Location: Riga, Latvia

Re: "print" to file truncating results at 80 columns

Mon Feb 08, 2016 4:06 pm

did you try "print detail" and "print detail without-paging" ?
 
User avatar
ScottReed
Member Candidate
Member Candidate
Topic Author
Posts: 114
Joined: Thu Sep 24, 2009 9:47 pm
Location: Montana / Western Massachusetts

Re: "print" to file truncating results at 80 columns

Mon Feb 08, 2016 4:41 pm

did you try "print detail" and "print detail without-paging" ?
Normis, thank you so much for your reply.

Yes, I have. That works fine for preserving all the details, but the output is not in selectable columns.

I could write some code to take the "print-details" output and get the data I want, but it seems to me that a standard "print" to a file should preserve the exact same formatting as it shows in the terminal and not truncate at 80 columns.

The point here is that you can take the terminal output of:
/ip dhcp-server lease print without-paging where ! dynamic and status="bound"
And copy/paste it into Notepad++ and then Alt-Select whichever column you want (Address, MAC, HOST, SERVER) etc...

That same command, with output to a file, simply truncates out at 80 columns. It's not helpful because it basically chops the data after the MAC-ADDRESS.
 
spuhpointer
just joined
Posts: 4
Joined: Tue Feb 12, 2008 3:05 pm

Re: "print" to file truncating results at 80 columns

Mon Oct 05, 2020 11:51 pm

When used from third party terminal via SSH login, then truncation still affects:
$ ssh someuser+200w\@x.y.z.2 -C '/ip dhcp-server lease print without-paging'

Flags: X - disabled, R - radius, D - dynamic, B - blocked 
 #   ADDRESS                                      MAC-ADDRESS       HO SER.. RA
 0   x.y.z.84                                 F0:DE:F1:7D:FF:FF ma dhcp1
     x.y.z.67                                 B8:FF:EB:A3:FF:FF ra dhcp1
     x.y.z.125                                E0:FF:47:31:FF:FF Ma dhcp1
 3   x.y.z.139                                D8:FF:85:E1:FF:FF vo dhcp1
 4   x.y.z.90                                 00:FF:28:B1:FF:FF    dhcp1
 5 D x.y.z.17                                 88:FF:24:22:FF:FF Ch dhcp1
 6 D x.y.z.69                                 48:FF:4E:35:FF:FF NP dhcp1
 7 D x.y.z.117                                F8:FF:27:12:FF:FF EP dhcp1
 8 D x.y.z.62                                 E8:FF:FC:C1:FF:FF ji dhcp1
 9 D x.y.z.155                                3C:FF:82:25:FF:FF NP dhcp1
10 D x.y.z.19                                 78:FF:76:B0:FF:FF vu dhcp1
11 D x.y.z.82                                 78:FF:C0:C1:FF:FF DA dhcp1
12 D x.y.z.79                                 30:FF:A7:BF:FF:FF SE dhcp1
13 D x.y.z.115                                00:FF:00:31:FF:FF ET dhcp1
14 D x.y.z.75                                 84:FF:19:27:FF:FF SE dhcp1
Thus it is no possible to grep/awk out the host names...
So any ideas how to solve this?
 
GustavandCat
just joined
Posts: 1
Joined: Sat Jan 29, 2022 8:48 pm

Re: "print" to file truncating results at 80 columns

Sat Jan 29, 2022 8:50 pm

This is messy but it is working for me.
attaching a pseudo-terminal and quitting

ssh -t -l status -i .ssh/id_rsa-mikrotik-ro 192.168.2.1 "ip dhcp-server lease print without-paging;quit" | head -n -3
Last edited by GustavandCat on Sat Jan 29, 2022 8:51 pm, edited 1 time in total.

Who is online

Users browsing this forum: No registered users and 17 guests