[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] Question: Capturing command output (on-screen keyword co
From: |
Matthew Giassa |
Subject: |
Re: [Help-bash] Question: Capturing command output (on-screen keyword colorizer/prettifier). |
Date: |
Wed, 05 Oct 2016 09:35:43 -0700 |
User-agent: |
Workspace Webmail 6.5.1 |
Ah, my mistake. I had thought it was a shell builtin. `type` quickly
corrected that notion.
Thank you.
============================================================
Matthew Giassa, MASc, BASc, EIT
Security and Embedded Systems Specialist
linkedin: https://ca.linkedin.com/in/giassa
e-mail: address@hidden
website: www.giassa.net
> -------- Original Message --------
> Subject: Re: [Help-bash] Question: Capturing command output (on-screen
> keyword colorizer/prettifier).
> From: Chet Ramey <address@hidden>
> Date: Wed, October 05, 2016 7:18 am
> To: Matthew Giassa <address@hidden>, address@hidden
> Cc: address@hidden
>
>
> On 10/4/16 9:20 PM, Matthew Giassa wrote:
>
> >
> > While I'm able to get the output of echo commands, the PS1/PS2/etc
> > variables, and so on, I can't seem to get the output of the "ls" command
> > for
> > example. I've checked the symbols used to write data out to the console
> > via the
> > following: readelf --dyn-syms /bin/bash | grep -i -e write -e printf
> >
> > Output:
> > 6: 0000000000000000 0 FUNC GLOBAL DEFAULT UND
> > address@hidden (5)
> > 13: 0000000000000000 0 FUNC GLOBAL DEFAULT UND
> > address@hidden (5)
> > 39: 0000000000000000 0 FUNC GLOBAL DEFAULT UND
> > address@hidden (2)
> > 98: 0000000000000000 0 FUNC GLOBAL DEFAULT UND
> > address@hidden (8)
> > 142: 0000000000000000 0 FUNC GLOBAL DEFAULT UND
> > address@hidden (5)
> > 152: 0000000000000000 0 FUNC GLOBAL DEFAULT UND
> > address@hidden (5)
> > 191: 0000000000000000 0 FUNC GLOBAL DEFAULT UND
> > address@hidden (2)
> > 192: 0000000000000000 0 FUNC GLOBAL DEFAULT UND
> > address@hidden (5)
> > 213: 0000000000000000 0 FUNC GLOBAL DEFAULT UND
> > address@hidden (5)
> >
> > So as far as I can see, I'm hooking all of the typical commands BASh
> > would use to write to the console, yet there is still output which I'm
> > not
> > capturing.
> >
> > Is there yet another function BASh uses which I would need to hook in
> > order to capture all command output within the LD_PRELOAD'ed C library?
>
> Since `ls' is a separate executable, it handles input and output itself.
> Bash doesn't get involved with it.
>
> If you want to hook the separate child processes to your LD_PRELOAD
> library, you need to make sure that LD_PRELOAD survives the fork and
> is available to the loader. That might be as simple as exporting the
> variable.
>
> --
> ``The lyf so short, the craft so long to lerne.'' - Chaucer
> ``Ars longa, vita brevis'' - Hippocrates
> Chet Ramey, UTech, CWRU address@hidden http://cnswww.cns.cwru.edu/~chet/