Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   Debian User (http://www.linux-archive.org/debian-user/)
-   -   Wondering about the print out function of PS (http://www.linux-archive.org/debian-user/456347-wondering-about-print-out-function-ps.html)

Magicloud Magiclouds 11-23-2010 05:38 AM

Wondering about the print out function of PS
 
Hi,
The output of `ps`, is trunked by the width of the terminal, without
wrapping like `ls`.
I looked into the source of output, confused by the code.
May I have some clue here? How does `ps` know the width of the
terminal, or I was mislead, `ps` prints over the behavior of printf
()?
--
竹密岂妨流水过
山高哪阻野云飞


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: AANLkTi=p0TNyFdZiMpJEE3eSPXKDQVrYN+Ronyp1qikJ@mail .gmail.com">http://lists.debian.org/AANLkTi=p0TNyFdZiMpJEE3eSPXKDQVrYN+Ronyp1qikJ@mail .gmail.com

Camalen 11-23-2010 06:48 AM

Wondering about the print out function of PS
 
On Tue, 23 Nov 2010 14:38:33 +0800, Magicloud Magiclouds wrote:

> The output of `ps`, is trunked by the width of the terminal, without
> wrapping like `ls`.

(...)

You can force wrapping with "-w" (or "w") modifier:

ps auxw

Greetings,

--
Camalen


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: pan.2010.11.23.07.48.07@gmail.com">http://lists.debian.org/pan.2010.11.23.07.48.07@gmail.com

Magicloud Magiclouds 11-23-2010 07:12 AM

Wondering about the print out function of PS
 
Sorry, I meant to know how it could be "not wrapping". The source
somehow confused me.

On Tue, Nov 23, 2010 at 3:48 PM, Camaleón <noelamac@gmail.com> wrote:
> On Tue, 23 Nov 2010 14:38:33 +0800, Magicloud Magiclouds wrote:
>
>> * The output of `ps`, is trunked by the width of the terminal, without
>> wrapping like `ls`.
>
> (...)
>
> You can force wrapping with "-w" (or "w") modifier:
>
> ps auxw
>
> Greetings,
>
> --
> Camaleón
>
>
> --
> To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
> with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
> Archive: http://lists.debian.org/pan.2010.11.23.07.48.07@gmail.com
>
>



--
竹密岂妨流水过
山高哪阻野云飞


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: AANLkTinvsoXPF3iJkd6EUi=-u2FzsObS0K7XouruHcwg@mail.gmail.com">http://lists.debian.org/AANLkTinvsoXPF3iJkd6EUi=-u2FzsObS0K7XouruHcwg@mail.gmail.com

Camalen 11-23-2010 07:33 AM

Wondering about the print out function of PS
 
On Tue, 23 Nov 2010 16:12:50 +0800, Magicloud Magiclouds wrote:

> On Tue, Nov 23, 2010 at 3:48 PM, Camalen wrote:
>> On Tue, 23 Nov 2010 14:38:33 +0800, Magicloud Magiclouds wrote:
>>
>>> * The output of `ps`, is trunked by the width of the terminal,
>>> * without
>>> wrapping like `ls`.
>>
>> (...)
>>
>> You can force wrapping with "-w" (or "w") modifier:
>>
>> ps auxw

> Sorry, I meant to know how it could be "not wrapping". The source
> somehow confused me.

Then "ps aux | less -S" to get no wrapping+horizontal scroll? :-?

Greetings,

--
Camalen


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: pan.2010.11.23.08.33.44@gmail.com">http://lists.debian.org/pan.2010.11.23.08.33.44@gmail.com

Magicloud Magiclouds 11-23-2010 08:03 AM

Wondering about the print out function of PS
 
On Tue, Nov 23, 2010 at 4:33 PM, Camaleón <noelamac@gmail.com> wrote:
> On Tue, 23 Nov 2010 16:12:50 +0800, Magicloud Magiclouds wrote:
>
>> On Tue, Nov 23, 2010 at 3:48 PM, Camaleón wrote:
>>> On Tue, 23 Nov 2010 14:38:33 +0800, Magicloud Magiclouds wrote:
>>>
>>>> * The output of `ps`, is trunked by the width of the terminal,
>>>> * without
>>>> wrapping like `ls`.
>>>
>>> (...)
>>>
>>> You can force wrapping with "-w" (or "w") modifier:
>>>
>>> ps auxw
>
>> Sorry, I meant to know how it could be "not wrapping". The source
>> somehow confused me.
>
> Then "ps aux | less -S" to get no wrapping+horizontal scroll? :-?
>
> Greetings,
>
> --
> Camaleón
>
>
> --
> To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
> with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
> Archive: http://lists.debian.org/pan.2010.11.23.08.33.44@gmail.com
>
>
I meant code-wise, just using printf would give a wrap output, right?


--
竹密岂妨流水过
山高哪阻野云飞


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: AANLkTimD2gmRsG4mkYjPHQ1bo5fTTBvp9voNH4dBb7Um@mail .gmail.com">http://lists.debian.org/AANLkTimD2gmRsG4mkYjPHQ1bo5fTTBvp9voNH4dBb7Um@mail .gmail.com

Camalen 11-23-2010 08:24 AM

Wondering about the print out function of PS
 
On Tue, 23 Nov 2010 17:03:12 +0800, Magicloud Magiclouds wrote:

> On Tue, Nov 23, 2010 at 4:33 PM, Camalen wrote:

>>> Sorry, I meant to know how it could be "not wrapping". The source
>>> somehow confused me.
>>
>> Then "ps aux | less -S" to get no wrapping+horizontal scroll? :-?
>>
> I meant code-wise, just using printf would give a wrap output, right?

Ah... I haven't read the source code.

Do you see any call to the standard printf() function? It seems ps
command integrates some output formatting options :-?

Greetings,

--
Camalen


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: pan.2010.11.23.09.24.44@gmail.com">http://lists.debian.org/pan.2010.11.23.09.24.44@gmail.com

Magicloud Magiclouds 11-23-2010 08:29 AM

Wondering about the print out function of PS
 
On Tue, Nov 23, 2010 at 5:24 PM, Camaleón <noelamac@gmail.com> wrote:
> On Tue, 23 Nov 2010 17:03:12 +0800, Magicloud Magiclouds wrote:
>
>> On Tue, Nov 23, 2010 at 4:33 PM, Camaleón wrote:
>
>>>> Sorry, I meant to know how it could be "not wrapping". The source
>>>> somehow confused me.
>>>
>>> Then "ps aux | less -S" to get no wrapping+horizontal scroll? :-?
>>>
>> I meant code-wise, just using printf would give a wrap output, right?
>
> Ah... I haven't read the source code.
>
> Do you see any call to the standard printf() function? It seems ps
> command integrates some output formatting options :-?
>
> Greetings,
>
> --
> Camaleón
>
>
> --
> To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
> with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
> Archive: http://lists.debian.org/pan.2010.11.23.09.24.44@gmail.com
>
>
This is where I got confused. From my understanding of the code, ps
calculates the width of the screen/string, and cut the output source
string "manually".
But I do not know how it gets the width of the screen.

--
竹密岂妨流水过
山高哪阻野云飞


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: AANLkTikuOc4RaNBiVx0Mnms5qXkkjEAYZ_9vuoes_Mb0@mail .gmail.com">http://lists.debian.org/AANLkTikuOc4RaNBiVx0Mnms5qXkkjEAYZ_9vuoes_Mb0@mail .gmail.com

Camalen 11-23-2010 08:51 AM

Wondering about the print out function of PS
 
On Tue, 23 Nov 2010 17:29:49 +0800, Magicloud Magiclouds wrote:

> On Tue, Nov 23, 2010 at 5:24 PM, Camalen wrote:

>>> I meant code-wise, just using printf would give a wrap output, right?
>>
>> Ah... I haven't read the source code.
>>
>> Do you see any call to the standard printf() function? It seems ps
>> command integrates some output formatting options :-?
>
> This is where I got confused. From my understanding of the code, ps
> calculates the width of the screen/string, and cut the output source
> string "manually".
> But I do not know how it gets the width of the screen.

Well... gathering information about the running terminal is possible:

sm01@stt008:~$ stty -a | grep column
speed 38400 baud; rows 63; columns 86; line = 0;

But how does internally do "ps"? Dunno :-?

Greetings,

--
Camalen


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: pan.2010.11.23.09.51.35@gmail.com">http://lists.debian.org/pan.2010.11.23.09.51.35@gmail.com

Jochen Schulz 11-23-2010 09:24 AM

Wondering about the print out function of PS
 
Camalen:
> On Tue, 23 Nov 2010 17:29:49 +0800, Magicloud Magiclouds wrote:
>
>> But I do not know how it gets the width of the screen.
>
> Well... gathering information about the running terminal is possible:
>
> sm01@stt008:~$ stty -a | grep column
> speed 38400 baud; rows 63; columns 86; line = 0;

Or simply:

$ echo $LINES $COLUMNS
31 107

(Don't know whether that's terminal/shell-specific.)

J.
--
When I get home from the supermarket I don't know what to do with all the
plastic.
[Agree] [Disagree]
<http://www.slowlydownward.com/NODATA/data_enter2.html>

Carl Johnson 11-23-2010 04:11 PM

Wondering about the print out function of PS
 
Jochen Schulz <ml@well-adjusted.de> writes:

> Camalen:
>> On Tue, 23 Nov 2010 17:29:49 +0800, Magicloud Magiclouds wrote:
>>
>>> But I do not know how it gets the width of the screen.
>>
>> Well... gathering information about the running terminal is possible:
>>
>> sm01@stt008:~$ stty -a | grep column
>> speed 38400 baud; rows 63; columns 86; line = 0;
>
> Or simply:
>
> $ echo $LINES $COLUMNS
> 31 107

Or even more simply:

$ stty size
57 118

In reply to the original question, I think the curses interface can get
the terminal size. I haven't tried it from C, but in perl I use the
GetTerminalSize function in the Term::ReadKey module (in the debian
package libterm-readkey-perl). The shells should also send the signal
SIGWINCH to notify the user when the terminal size changes (WINdow
CHange?). The bash documentation state that LINES and COLUMNS are
automatically set when a SIGWINCH is received.
--
Carl Johnson carlj@peak.org


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 87lj4kufr4.fsf@oak.localnet">http://lists.debian.org/87lj4kufr4.fsf@oak.localnet


All times are GMT. The time now is 08:59 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.