0

上下文:Windows 7,ActiveState Tcl 8.6.1

% info tclversion
8.6
% info patchlevel
8.6.1

我有一个名为 SETCFG.EXE 的 C# 控制台模式应用程序。它位于 C:\BIN 中的路径上。

% set project corp
corp
% set method Recent
Recent
% exec -- [list c:/bin/setcfg.exe bobat.cfg inserter.${project}.Method $method]
couldn't execute "c:\bin\setcfg.exe bobat.cfg inserter.corp.Method Recent": no such file or directory

现在可能是我没有正确指定 tcl 代码——距离上次遇到已经很多年了——所以我会尝试执行一个字符串

% exec -- "c:/bin/setcfg.exe bobat.cfg inserter.${project}.Method $method"
couldn't execute "c:\bin\setcfg.exe bobat.cfg inserter.corp.Method Recent": no such file or directory

嗯......也许我需要把程序放在第一位,参数放在第二位......

% exec -- "c:/bin/setcfg.exe" "bobat.cfg inserter.${project}.Method $method"
Syntax:
        c:\bin\setcfg.exe cfg sym val
child process exited abnormally

列表中的参数?

% exec -- "c:/bin/setcfg.exe" [list bobat.cfg inserter.${project}.Method $method]
Syntax:
        c:\bin\setcfg.exe cfg sym val
child process exited abnormally

那么我做错了什么?我尝试了几种可能性。还有更多吗?

4

1 回答 1

3

您需要指定多个参数exec,而不是单个参数。你要

exec -- c:/bin/setcfg.exe  bobat.cfg  inserter.${project}.Method  $method

有时,您会看到将命令构造为列表的代码。在这种情况下,您将使用“splat”运算符将列表展开为单个元素。

set command [list c:/bin/setcfg.exe bobat.cfg inserter.${project}.Method $method]
exec -- {*}$command

请参阅exec 手册页Tcl 语法页

于 2013-10-19T11:37:23.173 回答