Ledger command does not return

40 views
Skip to first unread message

Stefan Tunsch

unread,
Apr 4, 2012, 4:37:41 AM4/4/12
to ledge...@googlegroups.com
Hi!

I am having trouble executing ledger commands.
The issue is that "register" commands do not return.

Ledger starts rendering the transactions, but once it get's half way
through, it stops with a last ":" colon sign.

Escaping from there only works with Ctrl+Z.

It accepts a log file name, and writes something to it. The content of
this log file does not seem to be informative.

When I do other commands like "balance" it works fine.

It seems to have something to do with the length of the report and the
size of the terminal.
If the length is too long, it stops.
If I maximize the terminal, it stops later.

Haven't seen this before, so I am not sure whether this is strictly
related to ledger, or not...


The point is, I would like to know what is causing this?
Is it a problem in the ledger file format?

How can I pinpoint the issue?

I am using ledger compiled from GitHub (I think from the master branch)
on Ubuntu 11.10.

Regards, Stefan Tunsch

John Wiegley

unread,
Apr 4, 2012, 5:53:25 AM4/4/12
to ledge...@googlegroups.com
>>>>> Stefan Tunsch <stunsch-Re5JQEe...@public.gmane.org> writes:

> How can I pinpoint the issue?

I would build with debug info, and use the --verify option.

After that, run your same command (before --verify) with "valgrind" in front
of the command.

John

Stefan Tunsch

unread,
Apr 4, 2012, 6:39:31 AM4/4/12
to ledge...@googlegroups.com
Valgrind and debug don't give me any hint.
But I now see that when the output is longer than the terminal window
size, I end up in a vi-like interface, or maybe in vi, where "q" quits
the process, and pagedown let's me see the missing info.

Not sure what's happening here.
Or is this supposed to be like this?

Regards, Stefan Tunsch

El 04/04/12 11:53, John Wiegley escribi�:

Craig Earls

unread,
Apr 4, 2012, 8:03:50 AM4/4/12
to ledge...@googlegroups.com
This is normal. Leder uses a pager to control output. It assumes you want to read all output not just see it whiz across the screen


On Wednesday, April 4, 2012, Stefan Tunsch wrote:
Valgrind and debug don't give me any hint.
But I now see that when the output is longer than the terminal window size, I end up in a vi-like interface, or maybe in vi, where "q" quits the process, and pagedown let's me see the missing info.

Not sure what's happening here.
Or is this supposed to be like this?

Regards, Stefan Tunsch



El 04/04/12 11:53, John Wiegley escribió:

Stefan Tunsch<stunsch-Re5JQEe...@public.gmane.org>  writes:
How can I pinpoint the issue?
I would build with debug info, and use the --verify option.

After that, run your same command (before --verify) with "valgrind" in front
of the command.

John


--
Craig, Corona De Tucson, AZ
enderw88.wordpress.com

Stefan Tunsch

unread,
Apr 4, 2012, 8:06:02 AM4/4/12
to ledge...@googlegroups.com
I see.
Thanks for the info.

Regards, Stefan Tunsch

El 04/04/12 14:03, Craig Earls escribió:

Craig Earls

unread,
Apr 4, 2012, 8:44:11 AM4/4/12
to ledge...@googlegroups.com
I should add that if you redirect ledgers output to a file it doesn't page.  It only does that when printing to stdout.

John Wiegley

unread,
Apr 4, 2012, 4:01:13 PM4/4/12
to ledge...@googlegroups.com
>>>>> Craig Earls <enderw88-Re5JQE...@public.gmane.org> writes:

> I should add that if you redirect ledgers output to a file it doesn't page. 
> It only does that when printing to stdout.

Or a bit more accurately: it only does that when displaying to a tty. If you
pipe the output to another program, it doesn't invoke the pager then either.

John

Stefan Tunsch

unread,
Apr 11, 2012, 10:03:24 AM4/11/12
to ledge...@googlegroups.com
I have started playing with this piping feature of ledger, and have seen
that while it does avoid the paging, it does not avoid the line cropping.
When an account is too long to fit into one line, ledger crops it
automatically.
This can be somewhat prevented, by using the option to display things wider.

But once you reach that limit, you hit the problem.

So, for example, if you have an account named
"Assets:Family:Budget:Vacation:Whatever" and this gets cropped to
something like "Assets:Family:Budget:Vac..." you cannot do a command
like "ledger register | grep Whatever".

I know this is a stupid example, but I guess you get the point.

What is the standard way to do this?
I know I can call ledger with python and execute a script on it.
I know I can use the xml option that will output the data in xml format,
without the cropping.

But what I would like is to be able to use something as simple as
piping, but without the cropping of lines.
Let's say for example I want to save the output to a file, it makes no
sense to have ledger crop the lines.


Regards, Stefan Tunsch


El 04/04/12 22:01, John Wiegley escribió:

Craig Earls

unread,
Apr 11, 2012, 11:01:21 AM4/11/12
to ledge...@googlegroups.com
You can write your own custom format and it will not crop the output.

If you can send me an example of what you want I can help you with the format string.


On Wed, Apr 11, 2012 at 07:03, Stefan Tunsch <stu...@gmail.com> wrote:

What is the standard way to do this?



Stefan Tunsch

unread,
Apr 11, 2012, 1:21:34 PM4/11/12
to ledge...@googlegroups.com
The point is that the format options seem to be too complicated for what I am saying.
They are for sure appropriate for the task and probably way more powerful than what I need, but I don't know where to even start.
The documentation about it lacks in my opinion some simple examples that do useful stuff.

Currently I am using balance and register commands and that's about it.
I was thinking on ways to parse ledger's output, got annoyed by the cropping and simply wanted to turn it off.

Regards, Stefan Tunsch



El 11/04/12 17:01, Craig Earls escribió:

Craig Earls

unread,
Apr 11, 2012, 1:38:14 PM4/11/12
to ledge...@googlegroups.com
The formatting commands are daunting.  I am trying to write documentation for them and can hardly figure out where to start.

This will get you started:

ledger reg --format "%(date) %(payee) %(account) %(amount) \n"

John Wiegley

unread,
Apr 11, 2012, 2:57:06 PM4/11/12
to ledge...@googlegroups.com
>>>>> Stefan Tunsch <stunsch-Re5JQEe...@public.gmane.org> writes:

> What is the standard way to do this? I know I can call ledger with python
> and execute a script on it. I know I can use the xml option that will
> output the data in xml format, without the cropping.

Try using --account-width=999. That should effectively disable cropping for
only the account. --payee-width=999 will disable cropping for the Payee.

John

Craig Earls

unread,
Apr 11, 2012, 3:32:09 PM4/11/12
to ledge...@googlegroups.com
If you want something easy to parse you could use some like this:
ledger reg --format "|%(date)  |%(payee) |%(account) |%(amount) \n%/|%\$3| %\$4\n"

John Wiegley

unread,
Apr 11, 2012, 7:38:51 PM4/11/12
to ledge...@googlegroups.com
>>>>> Craig Earls <enderw88-Re5JQE...@public.gmane.org> writes:

> If you want something easy to parse you could use some like this: ledger reg
> --format "|%(date)  |%(payee) |%(account) |%(amount) \n%/|%\$3| %\$4 \n"

That's essentially the same as using the "org" report instead of the
"register" report, btw. There's also the "cvs" and "xml" reports for
script consumption.

John

Reply all
Reply to author
Forward
0 new messages