how to use another account to run commend in the same script

I want to run some script in my own account in one script and meanwhile need to access as root to run some commend and come back to the same script to continue the process. Any idea how the this can be achieved ???

Example:

I need to run a script using my id only on 'cuibi' dir, but needs to login as root to run some other command in the same script. Then, come back to user cuibi.

I saw some guru said to use 'sudo'. But the problem is that if I use 'sudo' command in my script, the promt ask me to type in the password. But I don't want the promt to come up. Can I just save the password in my script and input to the promt?

Thank you very much.

  • Cuibi

i think sudo can configure it as flexible as without any password input.

you may contact DBA for help, we do have this kind of function in our production apps.