this just gets weirder and weirder

all i want to do is execute a simple tar command with an --exlude option.

if i type the command into the terminal it works exactly as it should.

cd "/Volumes/COLD STORAGE/144000-144999/144073"; gnutar czvf "/Volumes/Cold_Storage_5/144000-144999/144073.tgz" *  --exclude="print drive"/*

if I try to process that command with applescript using

set command to "cd \"/Volumes/COLD STORAGE/144000-144999/144073\"; gnutar czvf \"/Volumes/Cold_Storage_5/144000-144999/144073.tgz\" *  --exclude=\"print drive\"/*"
do shell script command

it does work correctly. The files get tarred, but it does not issue the exclude command

if i try to process that command using

set command to "cd \"/Volumes/COLD STORAGE/144000-144999/144073\"; gnutar czvf \"/Volumes/Cold_Storage_5/144000-144999/144073.tgz\" *  --exclude=\"print drive\"/*"
do script command

it works perfectly in applescript. However, the rest of my script rely’s on this command being executed, and since do script doesn’t wait for the command to be processed the rest of my script fails.

if i try to write the string to a file and then use do shell script to execute that file, it still does not see the exclude command.

if i try to use that exact same file that the applescript wrote the string to, in the terminal manually, it works.

the problem is not related to using wildcards. (the command WORKS in the terminal)
the problem is not related to quotes in the wrong places, or not using single quotes. (again, the command WORKS in the terminal, and applescript WRITES the information to a file correctly, which is then CORRECTLY executed in the terminal.)
I have tried every variation of the exclude command.
I have tried it with local folders, with no luck.

I believe the PROBLEM is with the APPLESCRIPT command do shell script

but, I can’t believe that someone somewhere else, has never needed to issue the --exclude command with applescript before.
could someone please try this scenario, in their environment and let me know if it works.

Thanks in advance,
-Pendal

Your version with do shell script works for me. The contents of “print drive” are excluded. The dir “print drive” is in the tar file, but it is empty. To prevent getting even the empty dir in the archive, I dropped the “/*” part of your exclude pattern.

Your do script version just results in a syntax error. Maybe you were directing it at Terminal (where do script is a valid command) and just not showing us that context.

Since you are working on a command that runs OK in Terminal, but not in do shell script, you should read TN2065. One possibility is that your command line is using a different version of gnutar. You could check for that with something like this:

set program to "openssl" -- or gnutar, .
do shell script "printf 'do shell script: %s
Terminal: %s' \"$(type " & quoted form of program & ")\" \"$(bash -lc 'type '" & quoted form of quoted form of program & ")\""
(* Might return
"do shell script: openssl is /usr/bin/openssl
Terminal: openssl is /opt/local/bin/openssl"
*)

That said, there are a couple of cleanups you might want to do:

(* Changes:
 *	* Use 'quoted form of' instead of embedded double-quotes.
 *	*Put the '/*' of the exclude pattern into the quoted region.
 *	** The whole point of the --exclude option is to give a PATTERN to tar. Be sure to quote the wild card so that the shell will not (mis)interprete it.
 *	** Probably, this does not change anything. As the shell saw it, the string was «--exclude=print drive/*». Because the * wildcard was not quoted, the shell will try to do filename expansion with it. But, unless there is a dir named «--exclude=print drive», the pattern (as the shell sees it) would fail to match any files. When no files match a wildcard, bash (and many Bourne shells) pass the wildcard through as if it had been quoted (unless the nullglob or failglob shell options were set). Thus gnutar gets an argument of «--exclude=print drive/*». To prevent the shell from possibly expanding the wildcard, quote it.
 *	* Only run gnutar if the script was able to 'cd' to the source dir (use '&&', not ';' ).
  *	** If the cd fails (e.g. the source dir does not exist), the script would otherwise end up trying to tar up everything accessible on your computer, as the usual cwd for 'do shell script' programs is the root of your boot volume.
 *)

set srcDir to quoted form of "/Volumes/COLD STORAGE/144000-144999/144073"
set destFile to quoted form of "/Volumes/Cold_Storage_5/144000-144999/144073.tgz"
set excludePattern to quoted form of "print drive/*"

set command to "cd " & srcDir & "&& gnutar czvf " & destFile & " * --exclude=" & excludePattern
do shell script command

Fully quoting the exclude pattern and using conditional execution are worth doing even if you do not switch to using quoted form of (though I highly recommend doing that also).

Model: iBook G4 933
AppleScript: 1.10.7
Browser: Safari 4.0.2 (4530.19)
Operating System: Mac OS X (10.4)

Ahh … that tech note was a lifesaver.

i ended up having to switch my shell using the info in that.

Thank you much.

I’ve wasted a week on the problem.

-P