Page 1 of 1

"print" to file truncating results at 80 columns

Posted: Fri May 15, 2015 10:51 pm
by ScottReed
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

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

Posted: Tue Feb 02, 2016 3:13 pm
by scriptinfu
I was wondering if you ever found a solution to this bug?

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

Posted: Tue Feb 02, 2016 3:17 pm
by scriptinfu
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?

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

Posted: Thu Feb 04, 2016 3:18 pm
by ScottReed
No.

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

Posted: Thu Feb 04, 2016 4:11 pm
by mrz
I assume that you are worried that some of the fields are not visible.?

'print details' outputs all parameters and doe snot truncate anything.

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

Posted: Thu Feb 04, 2016 4:19 pm
by ScottReed
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.

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

Posted: Thu Feb 04, 2016 7:08 pm
by scriptinfu
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?

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

Posted: Thu Feb 04, 2016 7:19 pm
by scriptinfu
mrz,

It seems your solution works. Thank you.

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

Posted: Sat Feb 06, 2016 6:00 am
by changeip
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

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

Posted: Mon Feb 08, 2016 4:04 pm
by ScottReed
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.

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

Posted: Mon Feb 08, 2016 4:06 pm
by normis
did you try "print detail" and "print detail without-paging" ?

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

Posted: Mon Feb 08, 2016 4:41 pm
by ScottReed
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.