[sudo-users] Sudo and setting current environment variables

megadethpaw megadethpaw megadethpaw at hotmail.co.uk
Thu Aug 27 05:23:17 EDT 2009


I want to use sudo to run some tasks as a different user without having to supply a password, I've done this many times before without problem using different commands I want to run, but the one I want to use now has me stumped.

At the moment I log into a unix server and at the command prompt type the following:-

. ./senv.cfg ; db.status

this sets the current environment variables to point to areas where db's are kept, the db.status then tells me if they are up or down.

I have managed to set up sudo to allow the following command:-

/usr/bin/su <unix user> -c . ./senv.cfg; db.status

but I would prefer to be able to use sudo and the -u parameter to specify the unix user and just run the two commands after the "-c" of the su.

I have sudo 1.6.9p12 and 1.7.1 installed on my server so I can use commands applicable to either if need be.

Thanks for any assistance you can provide.


Windows Live Messenger: Thanks for 10 great years—enjoy free winks and emoticons.

More information about the sudo-users mailing list