Python scripting: how to input parameters $4, $5, etc

Bernard_Huang
Contributor III

Hi all,

I am interested in setting SSID order within Macbooks. So I searched JAMFNation (as I do) and I actually found the answer.
https://www.jamf.com/jamf-nation/discussions/18223/re-order-wifi-preferred-networks

So within this chat, the solution is provided as a python script, which I am very happy about. I have tested this within JAMF Pro 10.6, it works as expected.

But I would like to change the
PreferredSSIDs = ["SSID_1", "SSID_2", "SSID_3"] line to be
PreferredSSIDs = ["$4", "$5", "$6"] so that future JAMF Pro admin can easily see the listed SSID within the policy.

But $4, $5, $6 do not work in python script :(

Would any of you know how to read the $4, $5, etc parameter and parse it to the python script?

1 ACCEPTED SOLUTION

Bernard_Huang
Contributor III

Ok, I found my answer (It's actually quite satisfying to solve one's own problems :) )

So within Python script, use "import sys", then sys.argv[4] will equal $4, sys.argv[5] will equal $5, etc

So building on https://www.jamf.com/jamf-nation/discussions/18223/re-order-wifi-preferred-networks
the python scripting will look like:

import objc, ctypes.util, os.path, collections, sys from Foundation import NSOrderedSet PreferredSSIDs = [sys.argv[4], sys.argv[5], sys.argv[6]]

Hope this helps someone in the future :)

View solution in original post

2 REPLIES 2

Bernard_Huang
Contributor III

Ok, I found my answer (It's actually quite satisfying to solve one's own problems :) )

So within Python script, use "import sys", then sys.argv[4] will equal $4, sys.argv[5] will equal $5, etc

So building on https://www.jamf.com/jamf-nation/discussions/18223/re-order-wifi-preferred-networks
the python scripting will look like:

import objc, ctypes.util, os.path, collections, sys from Foundation import NSOrderedSet PreferredSSIDs = [sys.argv[4], sys.argv[5], sys.argv[6]]

Hope this helps someone in the future :)

rvera
New Contributor II

Thank you for this! I was hoping to find a solution without having to have different scripts for each ssid