Code Comments
Programming Forum and web based access to our favorite programming groups.I am trying to use tcl to create a dynamic like bat file so that I can
do backups of the "My Documents" folder. So I have the following line
in my tcl script.
puts $bkcmdid "zip -r \\\\intrepid\\samba\\hahmpc9bakup\\ryh-$tname.zip
c:\\Documents and Settings\\mydir\\My Documents\\*.*"
This creates the following line in the batch file.
zip -r \\intrepid\samba\hahmpc9bakup\ryh-Sunday_17Apr2005.zip
c:\Documents and Settings\mydir\My Documents\*.*
But the Windows batch language requires double quotes (") around the My
Documents path.
I am unable to figure out to create the double quotes I need. I tried
looking in the TCL book I have and scouring the internet, but I am able
to find a solution for this.
I apologize if this is a newbie like question, but I am a newbie to
tcl.
Post Follow-up to this messageAccording to maxima2k <rh10023@hotmail.com>: :I am unable to figure out to create the double quotes I need. Try something like this: $ tclsh puts [format "zip -r \"%s\" \"%s\"" [file join intrepid samba $tname.zip] [f ile join c: "Documents and Settings" mydir "My Documents" *.*] ] where you put within the file join command the pieces of your filename - wit hout all those backslashes. Put the pieces with spaces in quotes. And use those \" to insert the required quotes in the resulting string. -- <URL: http://wiki.tcl.tk/ > MP3 ID tag repair < http://www.fixtunes.com/?C=17038[/<...rg/NET/lvirden/ >
Post Follow-up to this messageOn 04/18/05 12:35, lvirden@gmail.com wrote:
> According to maxima2k <rh10023@hotmail.com>:
> :I am unable to figure out to create the double quotes I need.
> Try something like this:
>
> $ tclsh
> puts [format "zip -r \"%s\" \"%s\"" [file join intrepid samba $tname.zip]
[file join c: "Documents and Settings" mydir "My Documents" *.*] ]
>
I'm not on Windows but I think you should do something closer to this:
puts [format {zip -r "\\%s\%s" "%s"} intrepid \
[file nativename [file join samba hahmpc9bakup _ryh-$tname.zip]] \
[file nativename [file join "c:/Documents and Settings" mydir \
"My Documents" *.*]]]
Schelte
--
set Reply-To [string map {nospam schelte} $header(From)]
Post Follow-up to this message
According to Schelte Bron <nospam@wanadoo.nl>:
:On 04/18/05 12:35, lvirden@gmail.com wrote:
:> According to maxima2k <rh10023@hotmail.com>:
:> :I am unable to figure out to create the double quotes I need.
:> Try something like this:
:>
:> $ tclsh
:> puts [format "zip -r \"%s\" \"%s\"" [file join intrepid samba $tname.zip]
[file join c:
:"Documents and Settings" mydir "My Documents" *.*] ]
:>
:I'm not on Windows but I think you should do something closer to this:
:puts [format {zip -r "\\%s\%s" "%s"} intrepid \
: [file nativename [file join samba hahmpc9bakup _ryh-$tname.zip]] \
: [file nativename [file join "c:/Documents and Settings" mydir \
: "My Documents" *.*]]]
Hmm - why do you hard code the backslashes for intrepid? Is it something
special? If so, then perhaps the window users know what special thing shoul
d be
done to avoid hard coding those backslashes - the whole purpose of those
special file minor commands was so that the developer never had to hard code
slashes or backslashes, I thought.
--
<URL: http://wiki.tcl.tk/ > MP3 ID tag repair < http://www.fixtunes.com/?C=17038[/<...rg/NET/lvirden/ >
Post Follow-up to this messageOn 04/18/05 19:00, lvirden@gmail.com wrote:
> According to Schelte Bron <nospam@wanadoo.nl>:
> :On 04/18/05 12:35, lvirden@gmail.com wrote:
> :> According to maxima2k <rh10023@hotmail.com>:
> :> :I am unable to figure out to create the double quotes I need.
> :> Try something like this:
> :>
> :> $ tclsh
> :> puts [format "zip -r \"%s\" \"%s\"" [file join intrepid samba $tname.zi
p] [file join c:
> :"Documents and Settings" mydir "My Documents" *.*] ]
> :>
> :I'm not on Windows but I think you should do something closer to this:
> :puts [format {zip -r "\\%s\%s" "%s"} intrepid \
> : [file nativename [file join samba hahmpc9bakup _ryh-$tname.zip]] \
> : [file nativename [file join "c:/Documents and Settings" mydir \
> : "My Documents" *.*]]]
>
>
> Hmm - why do you hard code the backslashes for intrepid? Is it something
> special? If so, then perhaps the window users know what special thing sho
uld be
> done to avoid hard coding those backslashes - the whole purpose of those
> special file minor commands was so that the developer never had to hard co
de
> slashes or backslashes, I thought.
Intrepid appears to be a machine name, not part of the path. I assume
file join would join them togetether into a single backslash, giving
something with a completely different meaning.
The file minor commands are only for local files, I think. Like I said,
I'm not on Windows so I can't really check.
Schelte.
--
set Reply-To [string map {nospam schelte} $header(From)]
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.