On 5 Jan 2000, Eilert Brinkmann wrote:
eb> "S.Toms" wrote:
eb> > Ok, I havn't quite figure this out and it's bugging me prolly because I
eb> > have to use awk or somethign and don't understand it. What I'm trying to
eb> > do within a bash routine is extract the user from the output below
eb> > pipedream:/home/skull # who am i
eb> > pipedream!skull pts/2 Jan 4 21:48 (:0)
eb> >
eb> > in this case, skull. Does anyone wantto enlighten me? :)
eb>
eb> Use `whoami' instead of `who am i'.
eb>
Can't use 'whoami' as that will report the name of whom ever runs the
command rather then who initiated the xterm, rxvt, eterm, etc session. I
managed the following which seems to do what I'm looking for
who am i | awk '{split($1,a,"!"); print a[2]}'
based on what Ken posted, which will jsut print the owner of the display
rather then who the current user is. I'm doing this as withthe help from
Stefan, have worked out the following which will make the display
available to root when run from roots shell init script, in my case
.bashrc which is called by .profile
if echo $DISPLAY |grep -q '.'; then
USERDISPLAY=`who am i | awk '{split($1,a,"!"); print a[2]}'`
xauth merge /home/$USERDISPLAY/.Xauthority &>/dev/null
fi
eb> Eilert
eb>
--
S.Toms - tomas@primenet.com - homepage is in the works
SuSE Linux v6.2+ - Kernel 2.2.13
As long as the answer is right, who cares if the question is wrong?
--
To unsubscribe send e-mail to suse-linux-e-unsubscribe@suse.com
For additional commands send e-mail to suse-linux-e-help@suse.com
Also check the FAQ at http://www.suse.com/Support/Doku/FAQ/