switch user inside a script

Hi
Is there any way to switch user inside a shell script?

you can use sudo for that...
but there might be security constraints..

Use su or sudo.

Note that the user will only be switched for the duration of the commands run with either su or sudo.

If you want to do more as the other user, call another script with either of them.

You can use something like

scripts
.....
su - username
......

Or if you want to execute multiple set of commands using su, use

su - username -c "command1;command2;..."

Remember that if you are not using the - between su and username, the .profile of the user will not be sourced.

Thanks a lot!