LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   Setting perm env. variables for a super user. (http://www.linuxquestions.org/questions/slackware-14/setting-perm-env-variables-for-a-super-user-77624/)

Tarts 07-31-2003 07:17 AM

Bash perm. evar set in /etc/profile help
 
Hi, i would like to set some perm env. variables for bash, i am able to do it for root and my user account, but when i change to su i lose my evars. Any ideas would be most appreciated, im using slackware 8.1 by the way.

{edit}
I think i can explain this better:
Code:

if [ "`id -u`" = "0"]; then
  echo $PATH | grep /usr/local/sbin 1> /dev/null 2> /dev/null
  if [ ! $? = 0 ]; then
    PATH=/usr/local/sbin:/usr/sbin:/sbin:$PATH
    export PATH=$PATH:/Exec
    HOWTO=/usr/doc/Linux-HOWTOs
    MINI=/usr/doc/Linux-mini-HOWTOs
    cdrw=/dev/scd0
    floppy=/dev/fd0h1440
  fi
fi

The above works for root, and i can do it for my user account,
but when i change to root with su from my user account i lose
my evars, hope that clears things up, thanks again.

Tinkster 07-31-2003 05:23 PM

Try
su -
rather than su...

Cheers,
Tink

Tarts 08-01-2003 10:59 AM

:) :) :) Great! Let me guess 'man su', i don't know if i ever would have thought it was so easy, thank's though.
One more thing baffle's me:
Code:

[root][#] id -u && echo $?
0
0
[root][#]

How is:
Code:

if [ ! $? = 0 ]; then
true? (see code in post 1)
Thank's!

Tinkster 08-01-2003 05:13 PM

Quote:

Originally posted by Tarts
Code:

if [ ! $? = 0 ]; then

You've mixed to things up ;)

It doesn't check for the uid there,
but for the existence of /sbin in the path.
$? holds the success of the grep

Cheers,
Tink

Tarts 08-01-2003 05:34 PM

Ahh i think i get it. One more thing, where can i learn more about this, is this bash programming? Thank's for the reply's.

Tinkster 08-02-2003 04:03 PM

http://www.tldp.org/LDP/abs/abs-guide.html.tar.gz

:}

Cheers,
Tink

Tarts 08-02-2003 08:38 PM

The advanced bash scripting guide, i'm impressed! Thank's Tink.

Tinkster 08-02-2003 09:21 PM

Pleasure mate...

Next time I'll give the link a meaningful name :}

Cheers,
Tink


All times are GMT -5. The time now is 01:15 PM.