Using less to view output

Kenneth Brody kenbrody at bestweb.net
Sat May 14 17:46:55 PDT 2005


Quoting Jay R. Ashworth (Sat, 14 May 2005 19:42:26 -0400):
[... piping *report output through "less" ...]
> > How does this work on other systems?  How can you be scrolling through
> > a file within less, while at the same time be interacting with the
> > filePro menu that has been redisplayed?
>
> Because filepro is supposed to send it's output to *the pipeline*,

Correct.

> which is run by a subshell, and filepro shouldn't get control back
> until the pipeline exits.

Huh?

filePro is running the entire time.  Take the "normal" case where the
output is piped through "lp".  How could filePro not "get control back
until the pipeline exits" and yet still continue to generate the
output, as well as update the screen?  filePro never loses control.

Now, if filePro is sending its output to the screen while the output
is being piped to "lp", the same holds true for piping to "less".  So,
unless less waits for the input pipe to end before starting to show it
to the screen (which it does not, on any system I've seen other than
DOS/Windows), then filePro and less will both be sending their output
to the screen at the same time.

After all, doesn't this "work"?

    while true ; do time ; done | less

> I suspect strongly that this depends intimately on the semantics of the
> SYSTEM() system call, and that he might have better luck enclosing the
> pipeline (the series of semicolon-chained commands, which strictly
> speaking is *not* a pipeline) in explicit parenthesis.

This is not system(), but popen().  Now, it may be that popen() will
eventually call system(), but the fact remains that this is not "start
a child process and wait for it to end", but "run the child process in
parallel".

> Whether that will help *also* depends on the semantics of system; he
> might need to make the string of commands a shell script (which makes
> more sense anyway)...

The pipe is to the entire string of commands.  If you were to replace
it with something like "| read junk ; other commands", the first line
of the output would go to "$junk", and the rest if the output would
continue to the next command(s) on the line.

--
KenBrody at BestWeb dot net        spamtrap: <g8ymh8uf001 at sneakemail.com>
http://www.hvcomputer.com
http://www.fileProPlus.com


More information about the Filepro-list mailing list