Applescript not handling Tar command correctly.

I have this tar command.

gnutar cvf "/Volumes/Cold_Storage_5/144000-144999/144073.tar" "/Volumes/COLD STORAGE/144000-144999/144073" --exclude="/Volumes/COLD STORAGE/144000-144999/144073/print drive/*"

when i type that into the terminal the tar is created and the correct files are excluded.

when I try to do the exact same command using applescript, it only makes the tar file and does not exclude the files

any ideas?

here is the code that is issuing the command

[code]set commandToProcess to “gnutar cvf "/Volumes/Cold_Storage_5/144000-144999/144073.tar" "/Volumes/COLD STORAGE/144000-144999/144073" --exclude="/Volumes/COLD STORAGE/144000-144999/144073/print drive/*"”

to procCommand(commandToProcess)
try
with timeout of 1800 seconds
do shell script commandToProcess
end timeout
on error
log: "Command Not Processed: " & commandToProcess
end try
end procCommand[/code]
Can anyone explain why the line works in the terminal but does not work in applescript?
I cannot seem to get the exclude command for tar to work at all within applescript.

Any Ideas?

Thanks,
-P

Hi,

the problem is the wildcard (*) within the quotation. You can either put the wildcard after the double quote
or in this case I recommend to escape the spaces traditionally with a backslash


set commandToProcess to "gnutar cvf /Volumes/Cold_Storage_5/144000-144999/144073.tar /Volumes/COLD\\ STORAGE/144000-144999/144073 --exclude=/Volumes/COLD\\ STORAGE/144000-144999/144073/print\\ drive/*"
.

Note: the timeout block doesn’t affect shell scripts

hmmm … i tried both ways you mentioned.

and both tests produced the same results at the original… tar the directory but does not see the exclude command.

any other ideas?

ok … update

if i run the following in applescript it works …


set commandToProcess to "gnutar cvf \"/Volumes/Cold_Storage_5/144000-144999/144073.tar\" \"/Volumes/COLD STORAGE/144000-144999/144073\" --exclude=\"/Volumes/COLD STORAGE/144000-144999/144073/print drive/*\"

tell applcation "Terminal"
 activate
  do script commandToProcess
end tell


and it works. the only problem is using this method the script doesn’t wait for the tar command to finish before moving on.

it has to be something with the way the do shell script command parses everything after the – in the line.

is there anyway of “escaping” the – or maybe I can push them as ASCII instead.