• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 768
  • Last Modified:

su - pass in userid and password

How to pass in user id and password when executing 'su' command in a script?
0
sn8776
Asked:
sn8776
1 Solution
 
jonkeCommented:
Would it not be easier to run the script as root, then at the start su to a different user- that way you wouldn't need a password.
0
 
jonkeCommented:
Then you would just have to 'exit' back to root, to do something as root.
0
 
ahoffmannCommented:
su - user

password cannot be suplied, 'cause UNIX reads passwords from tty directly. If you realy need it, you have to use expect as scripting language.
0
[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

 
tfewsterCommented:
ahoffman - Couldn't you use su - user < file_containing_password or is su too smart to be cheated that way?
0
 
ozoCommented:
su is too smart to be cheated that way
But on some systems you may be able to
chown user script
chmod u+s script
0
 
sn8776Author Commented:
Hi all,

I was told that i can try out using "Sticky Bit", so I think will closed this question by giving the point to ahoffmann as he is the one to proposed the answer to me and I got answer for this question from u all clearly.

I also would much appreciate if any of you can tell me more about the "sticky bit" technics and may be where I can find more information about that.

No extra point for this.

Anyway, thanks for you all to repond to my question.

from
sn
0

Featured Post

Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now