Say you need to sudo as a particular user and run a command and at the same time you need to pass an environmental variable to the command, you can do it by passing the command in doublequotes.
For example, I want to start Oracle while I am logged in as another user (vinay), I can start the database using dbstart by issues
"sudo su - oracle -c "dbstart /$ORACLE_HOME"
$ORACLE_HOME is an environmental variable listed under user oracle’s environment.
Needless to say, you need to ensure that you have sudo configured to allow your userID to su to oracle.
[...] here to read the rest: Kudithipudi.Org » Blog Archive » HOW TO : Pass environment … Share and [...]
Pingback by Keeping Green » Kudithipudi.Org » Blog Archive » HOW TO : Pass environment … — May 21, 2009 @ 3:17 am
Hi, Excellent post, some really useful environmental information here and well worth knowing about.
Thanks
Comment by environmental information — June 28, 2009 @ 9:40 am