ID shell and process

Gerald Thurman nanofoo at gmail.com
Thu Aug 2 13:34:32 MST 2007


It should be noted that the 'ps | grep $$' command-line,
without any anchoring on the grep pattern, could result
in multiple lines of output.

On 8/2/07, der.hans <PLUGd at lufthans.com> wrote:
>
> Am 02. Aug, 2007 schwätzte Jon M. Hanson so:
>
> > der.hans wrote:
> >> moin moin,
> >>
> >> a question on another list about determining which shell is currently
> >> being used led to some nice answers.
> >>
> >> I thought I'd post some here in that the answers might not only be
> useful,
> >> but might lead to learning more about how things work.
> >>
> >> ls -l /proc/$$/exe
> >> readlink /proc/$$/exe
> >> cat /proc/$$/cmdline
> >> ps -p $$
> >> ps | grep $$
> >>
> >> If you haven't wandered around in proc you should check it out. If you
> >> have, you should likely look again :).
> >>
> >> /me looks again.
> >>
> >> ciao,
> >>
> >> der.hans
> >>
> > Another one is echo $0.
>
> Yup. That had been mentioned, but I forgot to add it to my email. I'm glad
> that someone thought about the post :).
>
> echo $SHELL was mentioned, but that one is actually unreliable when you
> have shells within shells.
>
> All of the others can also be unreliable in that things might not be
> called what you think, but they should generally give you information
> about how the current process was called.
>
> ln /bin/fredsownshell /bin/bash
> exec /bin/fredsownshell
>
> :)
>
> ciao,
>
> der.hans
> --
> #  https://www.LuftHans.com/        http://www.CiscoLearning.org/
> #  "It is a miracle that curiosity survives formal education."
> #   -- Albert Einstein
> ---------------------------------------------------
> PLUG-discuss mailing list - PLUG-discuss at lists.plug.phoenix.az.us
> To subscribe, unsubscribe, or to change your mail settings:
> http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.PLUG.phoenix.az.us/pipermail/plug-discuss/attachments/20070802/ab8d8985/attachment.htm 


More information about the PLUG-discuss mailing list