Converting a Terminal command in a shell script ...

Hi,

do shell script "hdiutil compact /Users/Nous/Sauvegardes/Duplication\ -\ iMacG5/Duplication\ -\ iMacG5.sparseimage"

Why does it return an error message ?

Except for the «do shell script» command, this is the command I inserted in Terminal and it works … Running it as a SS, it returns an error message. I think it’s because of the space in the file path. How can I run it as a shell script in an AppleScript.app file ?

Thanks in advance.

Robert Lespérance

Model: iMac Intel 3,06 GHZ
AppleScript: 2.3
Browser: Safari 4.0.4 (6531.21.10)
Operating System: Mac OS X (10.6)

Hello,

The slash is a reserved character in AppleScript as well as in `sh '. Therefore you have to protect/escape your slash with … a slash.

do shell script "hdiutil compact /Users/Nous/Sauvegardes/Duplication\\ -\\ iMacG5/Duplication\\ -\\ iMacG5.sparseimage"

But it is better to use the “quoted form of” instruction to free yourself of spaces and other reserved characters.

set aPath_px to "/Users/Nous/Sauvegardes/Duplication - iMacG5/Duplication - iMacG5.sparseimage"
do shell script "hdiutil compact " & quoted form of aPath_px

Thank you clemhoff,

The script returns «Resources temporarily unavailable». Do you have an idea what are these resources ? The «sparse image» file is not open and SuperDuper is not running or open, so it should not be holding the file neither.

Do you have an idea ?

Regards.

Robert

Sorry, no particular idea. Maybe a busy file

…from http://developer.apple.com/Mac/library/documentation/Darwin/Reference/ManPages/man1/hdiutil.1.html

ERRORS
DiskImages uses many frameworks and can encounter many error codes. In general, it tries to turn these
errors numbers into localized strings for the user. For background, intro(2) is a good explanation of
our primary error domain: the BSD errno values. For debugging, -verbose should generally provide
enough information to figure out what has gone wrong. The following is a list of interesting errors
that hdiutil may encounter:

[EAGAIN] Resource temporarily unavailable. As of OS X 10.5, DiskImages uses reader/writer
locks on its image files to prevent images from being attached on more than one
machine at a time (e.g. over the network). EAGAIN is returned if the appropriate
read or write lock can’t be obtained.


USING PERSISTENT SPARSE IMAGES


man 2 intro =>

error#35 EAGAIN Resource temporarily unavailable. This is a temporary condition and later calls to the same routine may complete normally.