I am trying to use sudo command in unix shell script. Its that it will do sudo and then search a file in the directory and then come out of the sudo account
my account = saurav
here is the script code
********************************
sudo -u abcd -s
cd /application/somefolder/
id
grep jdbc:oracle:thin server.properties
**************************************...
now how do i come out of the account to which i sudo, i can always use CTRL+D / ctrl + x from the prompt, but what should be used in the script to get out of the account back to my own account.
which is from abcd to saurav
Help with using sudo in a unix shell script?
why must you sudo as a user, then change directories, then check the id, then do a grep? shouldn't you do it all in one go?
if you setup your sudoers file correctly, the above could be accomplished with
sudo grep jdbc:oracle:thin /app/folder/server.properties
If you really need to use your version, try
exit
or else try su saurav
Let me know if that works or not, and feel free to ask more questions
-Eric
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment