Wednesday, 24 May 2017

How to get home directory by username and userid in nodejs?

Now I am writing a hook program, and it need run some scripts as different user identifications. For example, I start my program with sudo, and then run some script with node spawn function. I need set following arguments so that the script runs successfully:

spawn(cmd, {
  user: userid,
  group: groupid,
  env: {
    HOME: 'home directory of userid'
  }
}

I cannot find the node style solution to get the home direcotry by username or userid. So, how?



via Run

No comments:

Post a Comment