Posted on 02-25-2012 07:45 AM
We have just started using LightSpeed Filtering and I am looking for a way (extension Attribute) to determine it is installed on a computer. It adds two small clients on the computer but they are hard to find. It also adds two plist files to Library/Preferences. Does anyone have an extension attribute that I can use to find if these specific plist files are installed?
Solved! Go to Solution.
Posted on 02-26-2012 08:20 AM
ls's -l option gives you the long output, not grep.
you could do a simple test in bash, sort of like this:
#!/usr/bin/env bash
file="/etc/ntp.conf"
if [[ -e $file ]]; then
echo "yes"
elif [[ ! -e $file ]]; then
echo "no"
fi
in ruby (and other languages) you can make it even simpler. here's an example:
#!/usr/bin/env ruby
result = File.exist?("/etc/ntp.conf") ? "yes" : "no"
puts "<result>#{result}</result>"
likewise, if you're dealing with plugins, you probably want to track versions. here's an example in ruby: https://github.com/rockpapergoat/scripts/blob/master/misc/get_app_version.rb
Posted on 02-27-2012 01:35 PM
Excellent!! I had to add the <result> </result> so the JSS would report but other than that it works Great!!
#!/usr/bin/env bash
file="/Library/Preferences/com.lightspeedsystems.useragent.plist"
if [[ -e $file ]]; then
echo <result>yes</result>
elif [[ ! -e $file ]]; then
echo <result>no</result>
fi
Posted on 02-25-2012 10:29 PM
It's nothing super fancy but you can create a script for an extension attribute that lists a dir and then greps for a certain file name/type.
#!/bin/sh
result=`ls -l /dir/where/files/live | grep filename.filename`
echo "<result>$result</result>"
We use this @ my work to locate a .conf file that lives in /private/etc/ and a smart group that lists who has and who doesn't have the file, tied to this is an ongoing policy that installs the .conf file on machines that don't have it. I've not had much time to look into greps manual but when it prints the result it adds all of the file details
-rwxrwxrwx 1 root wheel 120 Jun 6 2011 sysctl.conf
I'm sure grep has a switch you can turn on to not print this info but due to laziness I've not looked into it.
Posted on 02-26-2012 08:20 AM
ls's -l option gives you the long output, not grep.
you could do a simple test in bash, sort of like this:
#!/usr/bin/env bash
file="/etc/ntp.conf"
if [[ -e $file ]]; then
echo "yes"
elif [[ ! -e $file ]]; then
echo "no"
fi
in ruby (and other languages) you can make it even simpler. here's an example:
#!/usr/bin/env ruby
result = File.exist?("/etc/ntp.conf") ? "yes" : "no"
puts "<result>#{result}</result>"
likewise, if you're dealing with plugins, you probably want to track versions. here's an example in ruby: https://github.com/rockpapergoat/scripts/blob/master/misc/get_app_version.rb
Posted on 02-27-2012 01:35 PM
Excellent!! I had to add the <result> </result> so the JSS would report but other than that it works Great!!
#!/usr/bin/env bash
file="/Library/Preferences/com.lightspeedsystems.useragent.plist"
if [[ -e $file ]]; then
echo <result>yes</result>
elif [[ ! -e $file ]]; then
echo <result>no</result>
fi
Posted on 02-28-2012 01:32 PM
There are several reasons why you shouldn't parse the output of ls. Not the least of which is calling an external command and spawning subshells.
Here are the really bad reasons why you should not do it.
Posted on 03-01-2012 03:16 PM
rmanly, Not sure what you are trying to say about the output of ls...