Skip to main content
Solved

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

  • September 26, 2018
  • 2 replies
  • 0 views

Forum|alt.badge.img+10

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?

Best answer by Bernard_Huang

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 original
Did this topic help you find an answer to your question?

2 replies

Forum|alt.badge.img+10
  • Author
  • Valued Contributor
  • 143 replies
  • Answer
  • September 26, 2018

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 :)


Forum|alt.badge.img+1
  • New Contributor
  • 4 replies
  • August 13, 2021

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

 


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings