Hi! I’m trying to write an application that handles a simple “rsync” shell command task. I build an array list with the command’s arguments and create the NSTask thing:
set arrayList to {"-CaviuE", "--filter='exclude .fseventsd'", src, tgt}
set rsync to current application's NSTask's alloc's init()
tell rsync
setStandardOutput_(outputpipe)
setStandardError_(outputpipe)
setLaunchPath_(cmdPath)
setArguments_(arrayList)
|launch|()
end tell
Note the second argument in arrayList. It contains a space character, which leads to an error and prevents the script from working. How can I circumvent whitespace in argument strings?
Thanks. But no luck. The shell command says now “No such file or folder” and seems to take that argument as a file path rather than an exclude instruction. Even when I try an argument with no whitespace character inside, like quoted form of “–stats”. Did I miss something?
Meanwhile I changed the code so much, I don’t get this error again. Now it resets my read pipe when I put in this argument. (The original one.) Can’t figure out why. But I managed to circumvent that whole thing by including a rule file for rsync. That works very well. Here’s what I did for everyone, who is encountering the same issues:
set arrayList to ¬
{ ¬
"-CaviuE", ¬
"--exclude-from=" & (current application's NSBundle's mainBundle's pathForResource_ofType_("excludes.txt", missing value) as string), ¬
src, tgt ¬
}