Re: Shell Aliases & .kshrc

From: Jean-Marc Monnez (monnez.jean-marc@AGORA.MSA.FR)
Date: Tue Feb 11 2003 - 11:26:40 EST


When you run 'su - user -c command' the command is exec-ed by the su
shell. You can verify it running :
-----------------------------------<screen
paste>----------------------------------------
root@seu106 /(164/0)>ps -f
     UID PID PPID C STIME TTY TIME CMD
    root 34798 32768 0 Feb 07 pts/8 0:00 -ksh
    root 38124 34798 4 17:11:59 pts/8 0:00 ps -f
root@seu106 /(165/0)>su - user -c "ps -f"
     UID PID PPID C STIME TTY TIME CMD
    root 34798 32768 0 Feb 07 pts/8 0:00 -ksh
    user 38132 34798 32 17:12:11 pts/8 0:00 ps -f
-----------------------------------<screen
paste>----------------------------------------
For each 'ps -f', the PPID is the initial ksh 34798 (no intermediate
process for su...).

This explains that aliases (and functions too) have disappeared.
Concerning your last question, you may turn around it with :
su - user -c '. $ENV ; alias'
if ENV contains the .kshrc path as usual.

Regards

-- JMM

-----------------------------
Jean-Marc MONNEZ
MSA / AGORA / ATD
monnez.jean-marc@agora.msa.fr
-----------------------------

Andrew Garnett wrote :

> All,
> I have a .kshrc file set up to create aliases. All
> works fine. When I log in to <user> they're all there,
> including one called startup.
> If I run su - <user> "-c startup" it says it doesn't
> exist. If I therefore run su - <user> "-c alias" none
> of the aliases are displayed.
>
> If I put some debugging messages in .kshrc I can see
> that when I call the above commands, .kshrc DOES get
> obeyed, and when I put an "alias" command at the end
> of .kshrc, the aliases ARE there.
> So it appears that the "su - user" command is logging
> in and running kshrc correctly, but the submitted
> command doesn't see the aliases.
> I've even tried dotting the .kshrc, but it can't be
> seen.
>
> Can anyone explain, or suggest how to run an alias
> with su
> Thanks,
> A
>
> __________________________________________________
> Do You Yahoo!?
> Everything you'll ever need on one web page
> from News and Sport to Email and Music Charts
> http://uk.my.yahoo.com





This archive was generated by hypermail 2.1.7 : Wed Apr 09 2008 - 22:16:35 EDT