How to "su" along with passwd within a shell script?

Hi,
I have a shell script in which I need to switch user and execute some commands and then come back to the original user. To make it more clear -
I have to log in as user xxx (this user is not root)- then 'su' to yyy - execute a script called zzz - then logout to xxx.
The problem I am currently facing is when I say "su -s id/passwd" it returns "id/passwd" user not found ......quite obvious isn't it?

I am using Sun Solaris 8.0. Thanks in advance for the help.

I spent some time trying to automate su in a ksh script on AIX, it couldn't be done so to get aroud it I used the perl telnet module (telnet the same box).

If you can't telnet directly as the user you want you could use sudo to allow user y to run a script as user x.
sudo -H -u user_to_run_as script_to_run

If the above are not what you want you could also use expect to automate the su. This site will get you started, there is also an expect perl module but the telnet module has replaced it.

http://www.oreilly.com/catalog/expect/chapter/ch03.html

Hope this helps

Hi,
Thanks a tonne ! I will let you know if I have further problems.