OK for clarity sake...you can write a script to "su" (switch user) and yes it will prompt for password unless you are root, then it will not. You will need to use a tool called expect as mentioned prior. I have provided you a link. http://expect.nist.gov/
You will need to install it on you box(s). Read thru the expect info and that should get you straight.
Hope this clears the issue.