TCL, UNIX, [exec] and lists

From: Phil Powell (soazine_at_erols.com)
Date: 12/31/03


Date: 31 Dec 2003 12:24:50 -0800

Consider now this code in TCL:

# USE GZIP WITH TAR TO CREATE tar.gz ZIPPED FILE OF ALL FILES IN
$fileList
regsub -all {/} $defaultDir {--} defaultDisplayDir; # CONVERT DEFAULT
DIRECTORY NAME TO A FILE-FRIENDLY FORMAT
set defaultDisplayDir [string range $defaultDisplayDir 2 end]; #
REMOVE FIRST 2 --
set tarFileName $archivePath/${defaultDisplayDir}_[clock scan
now].tar.gz
set cannotGzip [catch {
 exec tar zcf $tarFileName [string range $fileList 0 end]
} errMsg]
if {$cannotGzip} {
 writeErr $errMsg
 catch {exec rm $tarFileName} trash; # REMOVE "EMPTY" TAR FILE SINCE
ERROR OCCURRED AND NO FILES IMPORTED
 exit
}

I am going to take the list $fileList and import it into a UNIX TAR
command to tar.gz up a bunch of files whose names are in $fileList
into a .tar.gz file.

Problem is, it constantly fails. Here is the error generated each
time I try to use it:

[31/Dec/2003:15:03:02] tar:
/../internship_application_orig12082003112901.php
/../internship_application_orig12162003113501.php
/../internship_application_1072289535.php
/../internship_application_1072290610.php
/../internship_application_1072290994.php
/../internship_application_1072291038.php
/../internship_application_1072292211.php
/../internship_application_1072293322.php: Cannot stat: No such file
or directory
tar: Error exit delayed from previous errors

(for security reasons I am substituting the actual directory path with
"/../", sorry)

It apparently thinks the file name is all of $fileList, it doesn't
seem to know that I am importing $fileList as a list of string values.
 TCL knows what it is, but TAR does not.

Has anyone ever done [exec] with a list, using TCL 8.3 and Linux Red
Hat 7.3? I could use some advice here.

Thanx
Phil



Relevant Pages

  • TCL, UNIX, [exec] and lists
    ... set tarFileName $archivePath/$_[clock scan ... set cannotGzip [catch { ... I am going to take the list $fileList and import it into a UNIX TAR ... TCL knows what it is, ...
    (comp.unix.misc)
  • TCL, UNIX, [exec] and lists
    ... set tarFileName $archivePath/$_[clock scan ... set cannotGzip [catch { ... I am going to take the list $fileList and import it into a UNIX TAR ... TCL knows what it is, ...
    (comp.lang.tcl)
  • Re: System Command in TCL
    ... For things that have native support in Tcl - like copying ... For things that Tcl does not do for itself, such as "tar", ... There is a tar module in tcllib... ... lots of other stuff replacing system commands are in tcllib too... ...
    (comp.lang.tcl)
  • Re: How to install Expect on a Unix system
    ... on what was in the tar file, or where you got the tar file. ... :download the TCL languange as well. ... If you have to compile expect, then you are going to need a C compile ... environment as well as the Tcl source code. ...
    (comp.lang.tcl)