• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Synchronization Issues? or Why do my Shell Scripts Bite me after they are Done?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Synchronization Issues? or Why do my Shell Scripts Bite me after they are Done?


  • Subject: Synchronization Issues? or Why do my Shell Scripts Bite me after they are Done?
  • From: Jon Rosen <email@hidden>
  • Date: Sun, 19 Mar 2006 13:23:37 -0500

I've had an ongoing problem since upgrading a computer to 10.4. To recap, during our billing period, we generate PDF versions of our invoices. The invoices may be composed of over a dozen different reports from 4 different files. When printing an invoice to paper, that's irrelevant. When printing to PDF, there may be a dozen different PDFs that comprise a single invoice. They need to be merged into a single file. No problem. I use the PDFtk library to merge them into a single PDF using the cat output command and I call PDFtk from as a shell script from within the AppleScript.

My next step is to delete the individual files that are no longer needed. The problem that developed is that I get more than occasional Finder error messages telling me that these files are busy, and can't be moved to the trash. I tried adding delays, with varying degrees of success. Still no joy. Then, I had an inspiration. I thought to myself, if there is a synchronization issue where the shell script has not released the files, but control returned to the AppleScript, maybe I can wait for the process to end. So, I added the code below to my script.

Tell application "Finder"
with timeout of 20 seconds
set readyFlag to 0
repeat until readyFlag > 0
set processList to the name of every process
if processList contains "PDFtk" then
set readyFlag to 0
else
set readyFlag to 1
end if
-- We will check every half second to see if PDFtk is done merging PDF files
delay .5
end repeat
end timeout

update pdfFolder
delete pdfFolder's files
-- empty empties the Trash
empty


As you can see, I keep checking for the existence of the PDFtk process. When it is gone from the list of processes, I assume that it is safe to delete the files in the directory referred to as pdfFolder. I'm still getting the same error message, however. Is this approach not a good one. I realize it isn't working reliably, but it seems like a logical approach. Is there another way to find out if the files in a folder are available to be trashed?

TIA,

Jon


Jon Rosen ------------------------------------- VP, Information Technology STS Telecom Voice: 954-252-1006



_______________________________________________
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


  • Follow-Ups:
    • Re: Synchronization Issues? or Why do my Shell Scripts Bite me after they are Done?
      • From: Doug McNutt <email@hidden>
    • Re: Synchronization Issues? or Why do my Shell Scripts Bite me after they are Done?
      • From: Emmanuel <email@hidden>
  • Prev by Date: Re: Printer Setup Utility scripting??
  • Next by Date: Re: Synchronization Issues? or Why do my Shell Scripts Bite me after they are Done?
  • Previous by thread: Why doesn't this work in Address Book?
  • Next by thread: Re: Synchronization Issues? or Why do my Shell Scripts Bite me after they are Done?
  • Index(es):
    • Date
    • Thread