Skip to main content
Solved

Casper Remote Script Which Needs To Be Executed By Logged In User

  • June 14, 2017
  • 3 replies
  • 30 views

Forum|alt.badge.img+2

Script is being used to force a mail server address into the current Outlook account. Clients do not have admin rights and the script needs to be run under the logged in user. The markup below works great from within terminal while on the clients machine. However I'd like to have the script available within Casper Remote. I've looked through most of the threads that relate to 'executed by logged in user' without success. Thanks.

osascript -e "tell applications "Microsoft Outlook" to set server of exchange account 1 to "https://xxxSERVERxxxADDRESSxxHERE""

Best answer by kendalljjohnson

Same idea as above, but I have a couple scripts that use the following logic:

#!/bin/sh

#Define logged in user
user=`ls -la /dev/console | cut -d " " -f 4`

#Run command with sudo as user
sudo -u $user COMMAND

3 replies

Forum|alt.badge.img+10
  • Contributor
  • June 14, 2017

Ive had to run a few scripts as the user instead of root and I needed to prefix the command with "sudo -u $3"


Forum|alt.badge.img+16
  • Valued Contributor
  • Answer
  • June 14, 2017

Same idea as above, but I have a couple scripts that use the following logic:

#!/bin/sh

#Define logged in user
user=`ls -la /dev/console | cut -d " " -f 4`

#Run command with sudo as user
sudo -u $user COMMAND

Forum|alt.badge.img+2
  • Author
  • New Contributor
  • June 14, 2017

Thanks to you both for the help. I ended up using Kendall's markup, which worked perfectly.. Will be useful for anything going forward that requires the logged in user to be the executor.