Re: Windows 2000 and XP and exec and double quotes

From: Benjamin Riefenstahl (Benjamin.Riefenstahl_at_epost.de)
Date: 01/28/04


Date: Wed, 28 Jan 2004 12:28:43 +0100

Hi Richard,

rauletta@viawest.net (Richard Auletta) writes:
> Here is TCL:
>
> % exec cmd.exe /c echo hello
> hello
> % exec cmd.exe /c echo hello
> hello
> % exec cmd.exe /c echo "hello"
> hello

These look all correct to me. On the Tcl level the literal constants
hello, "hello" and {hello} mean the same string.

> % exec cmd.exe /c echo \"hello\"
> \"hello\"
> % exec cmd.exe /c echo {"hello"}
> \"hello\"
>
> This last one strikes me very odd.

These two are indeed where you hit the problem in Windows [exec].
Note that, as I said before, quotes can not occur in Windows filenames
(try it from Explore or from CMD.EXE, if you don't believe me), so the
fact that [exec] escapes quotes is not a problem with filename
parameters.

> As to why I want to include double quotes, that is what
> ntbackup wants.

Does ntbackup explicitly want quotes (like the FIND command does it)?
In that case you are hosed, because you can control the quoting the
[exec] does with that kind of detail.

OTOH, if ntbackup only needs quotes, iff the parameter contains
spaces, that is exactly how [exec] works, so this would not be a
problem.

> From the doc, clearly the " are in bold and are required (though not
> if the value does not contain spaces.)

Than everything is fine.

You can try out what actually happens, if you replace ntbackup with
this little batch instead:

>>>>>>> test.bat <<<<<<
@echo off
echo.|time >> c:\tmp\test.bat.log
echo %0 %* >> c:\tmp\test.bat.log
echo ----- >> c:\tmp\test.bat.log
>>>>>>> end of test.bat <<<<<<

benny



Relevant Pages

  • Re: Windows 2000 and XP and exec and double quotes
    ... arguments to exec. ... exec wish test1.tcl $cmd ... > quotes and escaping quotes in parameters with backslashes is a method ...
    (comp.lang.tcl)
  • Re: SQL password complexity
    ... a semicolon is an optional *statement* delimiter. ... EXEC sp_password NULL, 'new;password', 'DevLogin' ... the value isn't properly enclosed in single quotes: ... SQL Server MVP ...
    (microsoft.public.sqlserver.security)
  • Re: Long file name problem
    ... Jerold Schulman wrote: ... We cannot execute programs with long file names unless we wrap them in quotes. ... This is starting to cause some problem with programs on the system, as they don't wrap their commands in quotes by default. ... I had to do the same thing when install Back-up Exec. ...
    (microsoft.public.win2000.file_system)
  • Re: Windows 2000 and XP and exec and double quotes
    ... happens when Ido the same in tcl with exec. ... % exec cmd.exe /c echo hello ... The same command executed directly in cmd.exe ... ntbackup wants. ...
    (comp.lang.tcl)
  • Re: Windows 2000 and XP and exec and double quotes
    ... "cmd /c echo" just outputs it's commandline, so it's not very typical, ... mode of operation is not to try to escape the [exec] parameters. ... quotes and escaping quotes in parameters with backslashes is a method ...
    (comp.lang.tcl)