Quote:
Originally Posted by
Corona688
Your script shouldn't be doing sudo su - in the first place. Trying to automate an interactive login is the root of all that trouble. Just do sudo -u root /path/to/whateveryouwanttorun
Hi Corona,
I believe I could not put my question right way.
This is already a functionality in the bash_profile of root user to make sure if ever someone do "sudo su -" he/she should be asked question that why he is becoming root. That is achived by putting a script in bash_profile of root user that uses "read -p" to take input.
Now, the purpose of the function I wrote is not automating root login, but to check when authorized users do a "sudo su -" , they get a question prompt. So my function that i wrote is just to make sure if this functionality works.
if i do sudo -u root <Command> then I will not be able to capture the question that pops up from bash_profile of root user. I need to capture that string in a variable or in a file in an automated way.