Skip to main content
Solved

Search for python2 scripts in Jamf?


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

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 ðŸ˜…

View original
Did this topic help you find an answer to your question?

8 replies

Forum|alt.badge.img+15
  • Esteemed Contributor
  • 719 replies
  • 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
  • 141 replies
  • January 31, 2022
cbrewer wrote:

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
  • 5 replies
  • 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
  • 3533 replies
  • February 1, 2022
ega wrote:

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
  • 21 replies
  • 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
  • 141 replies
  • 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
  • 5 replies
  • February 1, 2022
Nick1403 wrote:

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?


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