Alias app rename (python) via Jamf Console

MacManDmac
New Contributor

Hey fellow Jamf users,

 

This is probably a very easy question, however its pulling my hair out,

 

Running the below command for instance to add an alias for Python works when ran us the user in terminal.

 

alias python='/usr/bin/python3'

 

Running this same command within Jamf as a script fails to change anything, I believe this is because it needs to be run as the logged in user,

 

To accomplish this I have the following which doesn't seem to do anything as well.

loggedInUser=$(stat -f%Su /dev/console)
su "$loggedInUser" -c 'alias python=/usr/local/bin/python3'

 

Any help will be great appreciated !

2 REPLIES 2

mm2270
Legendary Contributor III

 

#!/bin/zsh

logged_in_user=$(/usr/sbin/scutil <<< "show State:/Users/ConsoleUser" | /usr/bin/awk '/Name :/ && ! /loginwindow/ {print $3}')
logged_in_uid=$(/usr/bin/id -u "$logged_in_user")

/bin/launchctl asuser "$logged_in_uid" /usr/bin/sudo -iu "$logged_in_user" alias python=/usr/local/bin/python3

 

Thanks for your prompt reply, it executes this script with no errors, however it still fails to attach the alias to python3 :(

 

any other ideas ?