rtrouton / rtrouton_scripts

Scripts to share
MIT License
1.3k stars 489 forks source link

delete_Jamf_Pro_Computers.sh does not work with python 3 #102

Closed peteostro closed 9 months ago

peteostro commented 9 months ago

get an issue with python -c 'import sys, json; print json.load(sys.stdin)["token"]

Errors out. Works with python 2

rtrouton commented 9 months ago

If you're receiving this error, you're on a version of macOS earlier than macOS Monterey 12.x. Those versions of macOS still have Python 2 available and the script runs fine with Python 2 set as the system Python version.

As macOS Monterey is now two OS major versions behind the current shipping OS of macOS Sonoma 14.1.1, the script will not be updated to address the scenario of "older than macOS Monterey and running Python 3.x".

peteostro commented 9 months ago

I'm using Redhat which comes with python 3

the error I get with python 3 is

File "", line 1 import sys, json; print json.load(sys.stdin)["token"] ^ SyntaxError: invalid syntax

When I run with python2 it works fine. Possible security issues installing python 2 as its EOL macOS Sonoma comes with python 3 not 2 so the script will also not work with the newer OS's

rtrouton commented 9 months ago

macOS Sonoma does not come with a system Python at all. Python was deprecated and removed from macOS by Apple as of macOS 12.3. Python 3 is available as part of Apple's developer tools, but is not included with macOS by default.

This script was written to run on macOS only and is not guaranteed to work correctly on any other OS platform.

peteostro commented 9 months ago

Ok thanks, Using Linux as we want this to execute from a server once a month. I've modified the script so it deletes computers that are in a smart group so it does not need a local file.

peteostro commented 9 months ago

to make it work with python 3 had to just add some () around print as its a function now (thanks stackoverflow)

print(json.load(sys.stdin)["token"])