Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Confusing su behaviour
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
goatcheese
n00b
n00b


Joined: 03 Nov 2005
Posts: 23
Location: Seoul, South Korea

PostPosted: Sun Apr 23, 2006 7:35 pm    Post subject: Confusing su behaviour Reply with quote

exhibit A:
Code:

rorschach ~ # su - db2inst1
db2inst1@rorschach ~ $ db2level
DB21085I  Instance "db2inst1" uses "32" bits and DB2 code release "SQL08020"
with level identifier "03010106".
Informational tokens are "DB2 v8.1.0.64", "s040812", "MI00086", and FixPak "7".
Product is installed at "/opt/IBM/db2/V8.1".


exhibit B:
Code:

rorschach ~ # su -c db2level - db2inst1
/bin/bash: db2level: command not found


Would really love to know whats going on here, I figured the two should behave identically.

[Edit]

I've read the su manpage and see where it mentions reseting the path, but I figured adding
the - should still let it process the users .bash_profile.
Back to top
View user's profile Send private message
grimm26
Guru
Guru


Joined: 23 May 2004
Posts: 313
Location: Chicagoland, IL

PostPosted: Mon Apr 24, 2006 6:13 am    Post subject: Reply with quote

You have your su syntax wrong. Try this:
Code:
su - db2inst1 -c db2level

_________________
"Blessed is he who finds happiness in his own foolishness, for he will always be happy".
Back to top
View user's profile Send private message
goatcheese
n00b
n00b


Joined: 03 Nov 2005
Posts: 23
Location: Seoul, South Korea

PostPosted: Mon Apr 24, 2006 9:15 am    Post subject: Oui Reply with quote

Already tried that. Same result. :(
Back to top
View user's profile Send private message
Genone
Retired Dev
Retired Dev


Joined: 14 Mar 2003
Posts: 9625
Location: beyond the rim

PostPosted: Mon Apr 24, 2006 1:07 pm    Post subject: Reply with quote

su will use the original $PATH to find the command you specify with -c, the sourced profile will be used by that command.
Basically the difference is in the execution order:
A)
- source profile
- find command (with new $PATH)
- execute command

B)
- find command (with old $PATH)
- source profile
- execute command
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum