nahrens007 / jamf-scripts

Repository for scripts used in Ashland University's Jamf environment.
5 stars 0 forks source link

Script breaks when run #3

Open cpeonepeloton opened 1 year ago

cpeonepeloton commented 1 year ago

when trying to run the script it errors out:

sudo python3 download_scripts.py
Traceback (most recent call last):
  File "/Users/Shared/scripts/download_scripts.py", line 132, in <module>
    main()
  File "/Users/Shared/scripts/download_scripts.py", line 102, in main
    tokenResponse = getToken()
  File "/Users/Shared/scripts/download_scripts.py", line 41, in getToken
    response = requests.request("POST", os.environ['JSS_URL'] + url, data=payload, headers=headers, auth=(os.environ['JSS_USER'], base64.b64decode(os.environ['JSS_PASSWORD'])))
  File "/opt/homebrew/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/os.py", line 680, in __getitem__
    raise KeyError(key) from None
KeyError: 'JSS_URL'
nahrens007 commented 1 year ago

Looks like the environment variable JSS_URL is not set properly. Please read through the instructions.

On Thu, Oct 20, 2022, 18:21 Gilbert Palau @.***> wrote:

when trying to run the script it errors out:

sudo python3 download_scripts.py Traceback (most recent call last): File "/Users/Shared/scripts/download_scripts.py", line 132, in main() File "/Users/Shared/scripts/download_scripts.py", line 102, in main tokenResponse = getToken() File "/Users/Shared/scripts/download_scripts.py", line 41, in getToken response = requests.request("POST", os.environ['JSS_URL'] + url, data=payload, headers=headers, auth=(os.environ['JSS_USER'], base64.b64decode(os.environ['JSS_PASSWORD']))) File @.***/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/os.py", line 680, in getitem raise KeyError(key) from None KeyError: 'JSS_URL'

— Reply to this email directly, view it on GitHub https://github.com/redninja2/jamf-scripts/issues/3, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC2XWNDQGDFQOOQBRJ2B3V3WEHAX5ANCNFSM6AAAAAARKS74OY . You are receiving this because you are subscribed to this thread.Message ID: @.***>

cpeonepeloton commented 1 year ago

I actually read the instructions well, and installed requests with pip3. This is how that portion looks like: JSS_URL = "https://nasajpl.jamfcloud.com"

nahrens007 commented 1 year ago

I believe the issue is you are running the script with sudo so your user environment variables are not used.

On Thu, Oct 20, 2022, 18:35 Gilbert Palau @.***> wrote:

I have that portion filled out correctly: JSS_URL = " https://nasajpl.jamfcloud.com"

— Reply to this email directly, view it on GitHub https://github.com/redninja2/jamf-scripts/issues/3#issuecomment-1286233290, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC2XWNAXXDYYPIKWHB6U4DDWEHCKLANCNFSM6AAAAAARKS74OY . You are receiving this because you commented.Message ID: @.***>