1

It is possible to change the user within a shell script by su - newuser; but what if the newuser needs authentication. How can I provide the password within the shell script?

None of the users is root.

  • Are you automating a non-interactive process? If so, you want sudo. Or do you want to prompt the user for a password? If so, can you assume that a user is logged in locally? – Gilles 'SO- stop being evil' Mar 2 '12 at 22:45
2

Using passwords in plain text files is not recommended. However, if no security risk is involved, create an expect script. Expect is a scripting language designed to interact with interactive shells and it is perfect for things like authentication or automation of processes that require a user to type in different things or select different options in a shell environment.

| improve this answer | |
2

You cannot that I am aware of. You can schedule the job with cron for other users via Su. Besides you NEVER should put a wheel users password in a clear text file

| improve this answer | |
  • very nice point! you're quite right! – Googlebot Mar 2 '12 at 7:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.