RunAsCurrentUser.exe equivelent for Mac

(imported topic written by pdentremont91)

Hi Guys,

I’m trying to run an apple script that runs as current user basically need to configure Outlook 2011 on a machine for a user that already exists so i can’t use the template. As BigFix runs as root, and is a true multiuser os, what is the best way to accomplish this? If someone has a better way of accomplishing this please let me know.

Thanks,

Thanks,

Peter d’Entremont

(imported comment written by Lee Wei)

You can use the UNIX switch user (su) command.

For example, for a per-command basis, it would be:

su user -c command

A example of an ActionScript (not tested)

delete __appendfile
appendfile #!/bin/sh
appendfile su leewei -c “/usr/bin/some_command”

delete "/tmp/runcommand.sh"
copy __appendfile “/tmp/runcommand.sh”

wait chmod +x "/tmp/runcommand.sh"
wait chown leewei "/tmp/runcommand.sh"
wait “/tmp/runcommand.sh”

Lee Wei

1 Like

(imported comment written by pdentremont91)

OK that seems good. But I also need to dynamically identify the user and if i am running as root do I need a password for the su user?

Peter d’Entremont

(imported comment written by Lee Wei)

{name of current user} will dynamically replace the static username with the actual logged on user.

The UNIX su command does not require password if you are root.

The TEM Agent does run as root, so no password required.