help for automated script

Hi ALL:
I need to write a script that will start bunch of servers. and these servers each has a sudo account and they need a passowrd.

I dont know where to start and look.

Can you please give me some hints or some sample code.

Thanks in advance.

splax

I am trying the basic thing first. Try to sudo with password and it is not working.
I have the passowrd stored in file "passwordfile" and my script:

#!/bin/sh
cat passwordfile | sudo -S su - myapp

But it is not working. any ideas.?

Almost all the program read password from "terminal" only. So better you run that script with root login or do setuid bit for those binary of daemon/server/program (risky)

even though the script is not reading the password from file, which is good, it is prompting for a password. So we got rid of that file (needs to enter the password).

Now, the remaining tasks are after sudo and loging with password, I need to run some commands in the sudo environment and after successful completion of these commands I have to logout and do sudo to a different account and then do the same.

Is there a way to run some commands in this sudo environment and capture the output check the status of these commands.??

please help.

password are read *only and ONLY from terminal for better security. There are some third party utilities like "accept" , using which you can play around. I never tried this one , but you are free to search for this in the net.

Regds,

Kaps