How to give password at run time in a shell script?

hi,

how can i pass a password automatically when a shell script is running.

i have shell script(runscript.sh) which call another shell script inside it as a different user.

runscript.sh contains

su - nemo -c "/bin/main_script.sh"

but when i execute "runscript.sh" it try to run main_script.sh and prompts for a password. so i have to give the password manually. is there a way so that the script automatically reads a password? or is there a way so it doesnot prompt for a password at all?

sudo serves this purpose.

how? please give some examples.. what option do i have to use with sudo?

Your sysadmin would have to set that up.

There's also a possibility of using expect, if you don't mind having your password stored in plain text.

Expect Thread

idnt have expect and spawn command installed in putty. is there a way in which i can i can pass the password in the same line as

su - nemo <password>

No. .

is it possible to use expect command without the spawn command.? if it is possible then how?

spawn is an expect command, or so I thought. There is a separate spawn daemon (see section 8 of the spawn manpage), but I can't say if that's what expect is using. I've never had cause to use expect, so it's best if you read the manual page, or online documentation, to understand it better.