Re: do shell script "ps -auxwww | grep rsync | grep -v grep"
Re: do shell script "ps -auxwww | grep rsync | grep -v grep"
- Subject: Re: do shell script "ps -auxwww | grep rsync | grep -v grep"
- From: Dave Lyons <email@hidden>
- Date: Fri, 14 Oct 2005 20:47:05 -0700
...
-- find out if it's running; don't care what the pid is
set rsyncRunning to (do shell script "ps auxww | grep rsync | grep -
v grep >/dev/null; echo $?")
if rsyncRunning is "0" then
...
Here are two things that will make your test somewhat more robust,
though only somewhat:
(1) Take out the "u" option to ps. This causes the user name to be
printed; since you don't need it in this case, omit it to avoid the
(unlikely) case that the user name contains "rsync" or "grep".
(Google for "Mr. Grep" reveals that there are actually people who
have "Grep" for a name. Really!)
(2) Avoid "grep -v grep", because this could exclude too much: If
the line of ps output containing "rsync" specifies pathnames, then
the pathname might refer to an item named "bigreport.txt" -- oops,
that contains "grep"! One way around that is to grep "[r]sync",
where "[r]" will match the character "r" but will not match the
string "[r]" when it "finds itself" in the process list.
The issue without a simple solution is false positives: There may be
other, unrelated "rsync" processes running, or processes that happen
to contain the name "rsync" (maybe the user is running some app named
"powersync"), or even that contain "rsync" in their command line
arguments. -- You can mitigate this somewhat, if you control how
rsync is launched in the first place, by launching it as "/usr/bin/
rsync" and grepping for the full pathname, maybe even with a blank
space before and after.
Cheers,
--Dave
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden