[CLUE-Tech] shell programming

Dave Price davep at kinaole.org
Wed Dec 11 04:21:21 MST 2002


On Wed, Dec 11, 2002 at 03:13:16AM -0800, David Guntner wrote:
> 
> You're looking at the wrong variable.  You want to use $LOGNAME instead of 
> $user.  Thus:
> 
> #!/bin/bash
> 
> if [ $LOGNAME = "root" ]; then
>   echo "Hello root"
> else
>   echo "You aren't root"
> fi
> 
> 
> Will do what you want.Q

Not with my bash ...  $LOGNAME does not change when you `su

[davep at ldpx:~/images]$ su
[root at ldpx images]# echo $LOGNAME
davep

[root at ldpx images]# echo $UID
0

... but $UID does ...

aloha,
dave





More information about the clue-tech mailing list