Fwd: perl script running...
Fwd: perl script running...
- Subject: Fwd: perl script running...
- From: "Mark J. Reed" <email@hidden>
- Date: Thu, 6 Oct 2005 19:26:23 -0400
not sure why this was rejected...
---------- Forwarded message ----------
From: email@hidden
<email@hidden>
Date: Oct 6, 2005 6:55 PM
Subject: Re: perl script running...
To: email@hidden
You are not allowed to post to this mailing list, and your message has
been automatically rejected. If you think that your messages are
being rejected in error, contact the mailing list owner at
email@hidden.
---------- Forwarded message ----------
From: "Mark J. Reed" <email@hidden>
To: Martha I Espinosa <email@hidden>
Date: Thu, 6 Oct 2005 18:54:10 -0400
Subject: Re: perl script running...
On 10/6/05, Martha I Espinosa <email@hidden> wrote:
> Hi,
>
> I'm stuck on a piece of code that uses grep to see if a perl script
> is running...
>
> Here's what I have
>
> do shell script "open -a /Applications/Utilities/Terminal.app /path
> to perl script
>
> set perlStatus to 0
> repeat until perlStatus = 1
> set status to do shell script "ps -x | grep perl"
That will (sometimes) return the grep itself (since the grep command
line includes the word "perl"), depending on random timing
considerations beyond your control. So it's safer to do
ps x | grep perl | grep -v grep
or save a process by using awk:
ps x | awk '(/perl/ && !/awk/)'
Even better, you can do the ps+awk just once to get the perl script's
process identifier, and then just wait for that process to terminate:
set pid to do shell script "ps x | awk '(/perl/ && !/awk/) {print $1}'"
set perlStatus to "running"
repeat while perlStatus is "running"
set perlStatus to do shell script "kill -0 " & pid & "&& echo 'running'"
end repeat
Of course, that's a pretty busy busy loop, so you might want to put a
delay in there before the "end repeat" so that it only checks, say,
once every second, or every 10 seconds, or whatever resolution you can
tolerate.
> if status is not equal to "" then
> set perlStatus to 1
> else
> set perlStatus to 0
> end if
> end repeat
>
> What I want to achive is: check to see if perl script is running and
> if it is then keep waiting until it is done... If it's done running
> then I want to quit terminal and continue with my applescript...
>
> Thanks in advance
>
>
>
> _______________________________________________
> 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
>
--
Mark J. Reed <email@hidden>
--
Mark J. Reed <email@hidden>
_______________________________________________
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