I like it - always multiple ways to skin the cat. I'll test and will incorporate it if it works as expected.
Silly me. Why didn't I think of that! Best method of all. No grep required.
--
Walter Rowe, 301-975-2885
Supervisor, System Hosting Services
Enterprise Systems Division
NIST, US Dept of Commerce
After some little changes it does shorten it down, although I still had to grep out the awk statement itself as it always finds itself.
On Sep 23, 2011, at 8:38 AM, Ness, Todd wrote:
entourageCheck=ps -ef | grep -v awk | awk '/Entourage.app/{print $2}'
vs
entourageCheck=ps -ax | grep -i "entourage" | grep -v "grep" | grep -v "/bin/sh ./entourageAlert" | awk '{print $1}'
Both seem to work fine. Thanks for the help all. Now to go and annoy some procrastinators.
if [ "$entourageCheck" != "" ]; then
#Annoy people
fi
exit 0
You haven't mentioned how you are launching your script, but launchd may be a good overall option for what you are actually trying to achieve.
If the app launches post a message on screen.
Sean
Essentially what I am doing except I'm using a JSS script policy, the "every 15" trigger and "once a day" for now. Later next week, I'll remove the "once a day" limit which will should motivate people even more.
-Aaron
entourageCheck=ps -ef | awk '//Entourage.app//{print $2}'
This will only find "/Entourage.app/" which doesn't match the "awk" command. I just tested this against Terminal.app (my terminal window).
wrowe:~ walter$ ps -ef | awk '/Terminal.app/ { print $0 }'
502 16047 249 0 2:45PM ?? 0:01.43 /Applications/Utilities/Terminal.app/Contents/MacOS/Terminal -psn_0_352342
502 16229 16050 0 2:47PM ttys000 0:00.00 awk /Terminal.app/ { print $0 }
wrowe:~ walter$ ps -ef | awk '//Terminal.app// { print $0 }'
502 16047 249 0 2:45PM ?? 0:01.82 /Applications/Utilities/Terminal.app/Contents/MacOS/Terminal -psn_0_352342
wrowe:~ walter$ ps -ef | awk '//Terminal.app// { print $1 }'
502
wrowe:~ walter$
--
Walter Rowe, 301-975-2885
Supervisor, System Hosting Services
Enterprise Systems Division
NIST, US Dept of Commerce