How to run a command with some other user id

Hi

Say I am running a script using my user id csaha. How can I run any specific command in the same sctipr using any other user id (say root). Definitely I have the password of root. Any idea how the same can be achieved ???

Example:

I need to run a script using my id (csaha) only on csaha dir, but needs to access few files in stadby dir (as shown below ).

Clearly visible I need to give +rx permission (i.e. need to run "chmod +rx standby") before that using my script and root userid and want to revert back once the script is complete.

[csaha@server-a home]# ls -ltr
drwxr-xr-x 4 csaha perforce 4096 Feb 15 20:12 csaha
drwx------ 54 perforce perforce 4096 Feb 16 03:05 standby

Thanks a lot to all in advance
C Saha

You can use 'su' to run a command as another user but it may prompt for password depending on who is running it.

su - someuser -c "/somecommand.sh"

But 'sudo' is better suited for this purpose.

http://www.courtesan.com/sudo/

But I dont want it prompt for password because I have to run it inside a script.

dogday's solution is probably the best if you're running it from a script... but you need to be root.

i'm not sure if there's any SECURE way of running a script as another user.

Indeed, DogDay's suggestion to use sudo is the only real way to implement a solution for this.

Cheers
ZB