|
Non-interactive user switch to root
Is is possible switch user from a non-root user to root user without entering the password interactively inside a korn shell script which is run by a non-root user?
e.g. I have a non-root user called infodba who is in dba group and I want to create a shell script which is executed by infodba user and inside the script I want to switch to root user without getting prompted for the password and run chmod 777 command against a directory then switch back to infodba and create a file inside the directory. I like to perform the below in one script run by infodba without getting prompted for password.
(1) TEST_DIR exists with the access below
ls -ld TEST_DIR
drwxrwxr-x 2 root sys 80 Nov 20 10:45 TEST_DIR
(2) Give full access to TEST_DIR by root
chmod 777 TEST_DIR
ls -ld TEST_DIR
drwxrwxrwx 2 root sys 80 Nov 20 10:46 TEST_DIR
(3) Create a file inside TEST_DIR using infodba
touch TEST_DIR/test.txt
Cheers
Steve
Unix version : HP-UX 11.11
|