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

turnstile
New Contributor

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""

1 ACCEPTED SOLUTION

kendalljjohnson
Contributor II

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

View solution in original post

3 REPLIES 3

msnowdon
Contributor

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

kendalljjohnson
Contributor II

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

turnstile
New Contributor

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.