5

Can I get correct $PATH when executing sudo -u db2inst -sh "db2"?

view full story
linux-howto

http://unix.stackexchange.com – I need to run sudo -u db2inst1 sh -c "db2 connect to db; db2 set schema Edumate; db2 \"select * from edumate_settings\"" but I don't want to specify absolute path to db2 If I run sudo -u db2inst1 sh -c "id;$PATH;ls /opt/ibm/db2/V9.7/bin/db2" I get correct $PATH where /opt/ibm/db2/V9.7/bin/ is present uid=1002(db2inst1) gid=107(db2iadm1) groups=16(dialout),33(video),107(db2iadm1),108(db2fadm1),1001(eduserver) sh: /sbin:/usr/sbin:/usr/local/sbin:/root/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/games:/usr/lib64/jvm/jre/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin:/opt/firebird/bin:/opt/ib (HowTos)