/bundles/itninjaweb/img/Breadcrumb_cap_w.png
The mac agent runs under the sudo context.  How can I run a script as the current logged in user on a mac.  
0 Comments   [ - ] Hide Comments

Comments

Please log in to comment

Answer this question or Comment on this question for clarity

Answers

0
Something like this might work too depending on what you need to do (Courtesy of macdude):

#!/bin/bash

CurUser=`/usr/bin/users`

PrefDir=/Users/$CurUser/Library/Preferences

/usr/bin/defaultswrite $PrefDir/com.apple.finder CreateDesktop -bool FALSE ## Command to effectCurrent User

 

/usr/bin/killallFinder


Answered 12/01/2014 by: jknox
Red Belt

Please log in to comment
0
What agent do you mean?
Answered 11/23/2014 by: vjaneczko
Eighth Degree Black Belt

Please log in to comment
0
it would be something like

runuser -l  userNameHere -c 'command'
No password is required to use runuser command and it must be run by root user only.

Options

  1. The -l option : Make the shell a login shell, uses runuser-l PAM file instead of default one.
  2. The -g group : Specify the primary group.
  3. The -G group : Specify a supplemental group.
  4. The -c COMMAND : Pass a single COMMAND to the shell with -c.
  5. --session-command=COMMAND : Pass a single COMMAND to the shell with -c and do not create a new session.
  6. -m : Do not reset environment variables.
Answered 11/24/2014 by: SMal.tmcc
Red Belt

Please log in to comment
Admin Script Editor
Admin Script Editor is an integrated scripting environment available free here at ITNinja

Share