View previous topic :: View next topic |
Author |
Message |
goatcheese n00b
Joined: 03 Nov 2005 Posts: 23 Location: Seoul, South Korea
|
Posted: Sun Apr 23, 2006 7:35 pm Post subject: Confusing su behaviour |
|
|
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 |
|
|
grimm26 Guru
Joined: 23 May 2004 Posts: 313 Location: Chicagoland, IL
|
Posted: Mon Apr 24, 2006 6:13 am Post subject: |
|
|
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 |
|
|
goatcheese n00b
Joined: 03 Nov 2005 Posts: 23 Location: Seoul, South Korea
|
Posted: Mon Apr 24, 2006 9:15 am Post subject: Oui |
|
|
Already tried that. Same result. |
|
Back to top |
|
|
Genone Retired Dev
Joined: 14 Mar 2003 Posts: 9625 Location: beyond the rim
|
Posted: Mon Apr 24, 2006 1:07 pm Post subject: |
|
|
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 |
|
|
|