Skip to main content
Answer

Search for python2 scripts in Jamf?

  • January 31, 2022
  • 8 replies
  • 37 views

ega
Forum|alt.badge.img+16
  • Valued Contributor

So we have a nice tool to looks at packages for scripts that might have deprecated languages in them (see https://github.com/scriptingosx/pkgcheck).  Has anyone created something to look at the first line of all the scripts in the JSS and report ?  I am guessing would have to use the JAMF API, to get <script_contents>, then match on the first line like in pkgcheck.  Anyone working on this?

Best answer by Nick1403

found this yesterday: https://github.com/laurentpertois/Search-Scripts-In-Jamf

 

I haven't tested it yet but you can try it 😅

8 replies

Forum|alt.badge.img+15
  • Esteemed Contributor
  • January 31, 2022

If you have access to your database you can do this pretty easily with a select statement.

select script_id,file_name from scripts where script_contents like '%python%';

ega
Forum|alt.badge.img+16
  • Author
  • Valued Contributor
  • January 31, 2022

If you have access to your database you can do this pretty easily with a select statement.

select script_id,file_name from scripts where script_contents like '%python%';

We are cloud hosted so this won't work for us but good tip for on prem. folks


Forum|alt.badge.img+1
  • New Contributor
  • January 31, 2022

Here is what I used to search, it searches both scripts and EA, https://github.com/laurentpertois/Search-Scripts-In-Jamf


sdagley
Forum|alt.badge.img+25
  • Jamf Heroes
  • February 1, 2022

We are cloud hosted so this won't work for us but good tip for on prem. folks


@ega It's a little brute force, but my approach for checking python use was to run https://github.com/jamf/JamfMigrator in Save Only mode to make a local copy of all of the Script objects in my JSS, and then searching the directory of exported scripts for 'python'.


Forum|alt.badge.img+7
  • Contributor
  • Answer
  • February 1, 2022

found this yesterday: https://github.com/laurentpertois/Search-Scripts-In-Jamf

 

I haven't tested it yet but you can try it 😅


ega
Forum|alt.badge.img+16
  • Author
  • Valued Contributor
  • February 1, 2022

@Nick1403 Great find!  works well! I did searches on 1828 scripts and 173 extension attributes for "/usr/bin/python",
"/usr/bin/perl" and "/usr/bin/ruby".  I created a Jamf account that could only read Scripts and Computer Extension Attributes.  One thing to note is that I also found serval scripts that were calling python without the full path (tsk).  Kudos to Lauren for the script!!


Forum|alt.badge.img+1
  • New Contributor
  • February 1, 2022

found this yesterday: https://github.com/laurentpertois/Search-Scripts-In-Jamf

 

I haven't tested it yet but you can try it 😅


I've tested it and it does work. I used https://github.com/laurentpertois/Search-Scripts-In-Jamf/blob/main/searchScriptsAndEAsInJamf.sh to also find any python reference in EAs.


Forum|alt.badge.img+8

Nice little script, worked for me flawlessly.

Question tho, is it enough to just disable the Policies/EAs that use Python to get rid of the jamfdeamon alerts? Or do the Scripts/EA's need to be deleted from the JSS alltogether?