Wait until "do shell script curl" has finished downloading

Hi guys,

when calling

do shell script "curl 'ftp://ftp.oreilly.de/pub/katalog/web20_broschuere.pdf' -o 'temp.pdf'"
--delay 5
set a to do shell script "mdls -name kMDItemNumberOfPages 'temp.pdf'"
do shell script "rm 'temp.pdf'"
return a

the answer will be (null) for the PDF’s page count if one does not wait until the download has finished. Is there any way to wait without using delay (since one doesn’t know how long the download takes)?

Thanks,
Lars

You can go into a repeat loop and check the size of the file being downloaded. If the size stops changing then the download has finished and you exit the repeat loop.

Hi,

this not a question of download timing.
cURL waits always until the process is finished. The problem is, that SpotLight must index the file.


do shell script "curl 'ftp://ftp.oreilly.de/pub/katalog/web20_broschuere.pdf' -o 'temp.pdf'"
do shell script "mdimport 'temp.pdf'"
set a to do shell script "mdls -name kMDItemNumberOfPages 'temp.pdf'"
do shell script "rm 'temp.pdf'"
return a

Thanks Stefan, works great!