Problems with ditto

I’m trying to copy a file to the library folder. This needs to be done with AuthorizationMBS because the library folder can only be access with password. Therefore I need a shellscript. But I’m having problems when the file has a space in the path. It can only be a problem with escaping.

The script is very simple:

#!/bin/sh /usr/bin/ditto $1 /Library/VServer_x64/databases

One of the variations I’ve tried in the Terminal:

sudo /Users/beatrixwillius/Documents/\\ Datei/Development/Mail\\ Archiver/Classes/MainClasses/Build\\ Automation/Server/createindex.sh "/private/var/folders/ym/cn7dn55x72j8w8b7l2rchlxm0000gn/T/TemporaryItems/mail archive.DBIndex"

This gives the error message:

ditto: can't get real path for source '/private/var/folders/ym/cn7dn55x72j8w8b7l2rchlxm0000gn/T/TemporaryItems/mail' ditto: can't get real path for source 'archive.DBIndex'

When I remove the space in the path then the Terminal command works.

Executing the script with AuthorizationMBS also doesn’t work:

[code]dim theAuthorisation as new AuthorizationMBS
if not theAuthorisation.SimpleNewAuthorization then Return false

dim theParameters(-1) as string
theParameters.Append(oldLocation.UnixpathMBS)
theAuthorisation.Execute(CopyScript.UnixpathMBS, theParameters, true)
if theAuthorisation.LastError = 0 then
dim theResult as Integer = theAuthorisation.Wait
end if[/code]

where CopyScript is the above script and oldLocation is the file in the temp directory. LastError is 512.

Any idea what I’m doing wrong?

Try single quotes around $1 within the script.

Or double quotes, I forget which.

Double. Single quotes will take it as a literal.

That said, I’d try single quotes around the mail archive path.

Thanks, guys!