How to Switch from Local user to root user from a shell script?

Hi,

I need to switch from local user to root user in a shell script.
I need to make it automated so that it doesn't prompt for the root password.

I heard the su command will do that work but it prompt for the password.
and also can someone tell me whether su command spawns a new shell or runs in the same shell as parent script?

You can configure "sudo" to execute commands without password (see NOPASSWD option). Man sudo, sudoers.

If you're on something other than Linux, you might have to install a sudo package. Most Linux distros include it in almost all config variations.