Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Possible Duplicate:
Run a shell script as a different user

While writing scripts to automate the intialisation of SVN mirror repositories (svnsync), I again ran into problems trying to start another script with another user's privileges.

# This outer script is always run with root privileges ("sudo")

# Create repository, set privileges, etc

# Set up remote mirror; this works fine! (SSH key authentication)
ssh svnsync@anotherserver /var/lib/svn/ $REPO

# Set up local mirror as "svnsync" user
# ???

How can I call the other script, on the same machine, as a different user? Note that the outer script is always executed as root so su'ing as anyuser should not be a problem.

I tried something like:

su svnsync; /path/to/ $REPO; exit

and get weird results. How are you supposed to do it? When it's so easy remotely it's probably possible locally, right? (For now, let's pretend running the outer script as the same "svnsync" user is not an option.)

I think the question title sucks, so please help me reword it if you can.

share|improve this question

marked as duplicate by Kyle Brandt, Dennis Williamson, womble, Sam, Chopper3 Jan 15 '10 at 18:20

This question was marked as an exact duplicate of an existing question.

Yeah, that was it, thanks! This can be closed. (But while it's open, if you want to post an answer I'll accept it.) – Jonik Jan 14 '10 at 15:15
up vote 0 down vote accepted

Duplicate of . I think you can close it yourself?

share|improve this answer
I could delete it, but I'd rather have it closed as dupe (so that the slightly differently worded versions match more google searches) – Jonik Jan 14 '10 at 15:24
Ah, that makes sense. – Kyle Brandt Jan 14 '10 at 15:29

Not the answer you're looking for? Browse other questions tagged or ask your own question.