Re: Detach and reattach to shell command
Re: Detach and reattach to shell command
- Subject: Re: Detach and reattach to shell command
- From: garbanzito <email@hidden>
- Date: Fri, 9 Aug 2002 16:47:01 -0600
at 2002 08 09, 07:00 -1000, they whom i call Reinhold Penner wrote:
Is there any other way to monitor the state of a detached shell
command? Maybe some variable I can access? Or any other method of
detecting when a file has been downloaded completely?
one solution would be to follow your shell command with a
command that set a semaphore of some sort, putting both in
the background together.. this example uses a file as a
semaphore, though i realize that is ugly:
property the_semaphore_path : ""
on background_semaphore(shell_cmd)
set the_semaphore_path to do shell script "jot -r -w
'/tmp/semaphore%f.txt' 1"
set full_cmd to "( " & shell_cmd & " ; touch " &
the_semaphore_path & " ) >/dev/null 2>&1 &"
do shell script full_cmd
end background_semaphore
on run
set my_task to "curl -O
ftp://somewhere.com/something.txt"
background_semaphore(my_task)
end run
now you need to periodically check for the the existence of
a file at the_semaphore_path, and delete the file once it's
been detected
another solution would be to determine the process id and
check its status with ps.. to assist with this it would be
great if do shell script returned a result record including
not just the shell's stdout but also a process id (i believe
there may be a third-party substitute for do shell script
which does this)
--
steve harley
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.