Clearcase find 命令与 Tcl 脚本和批处理文件结合使用:重定向不起作用

发布于 2024-11-27 10:49:54 字数 708 浏览 1 评论 0原文

又是我;-)

我尝试从批处理文件启动cleartool find 命令。该批处理文件从 Tcl 脚本获取参数。

批处理文件:

 SET VERARG="version(\main\LATEST) && !lbtype(%3)"
 cleartool find . -version %VERARG% -print > Y:\x\Logs\%3.log

Tcl 脚本:

 set v_cmd "y:\\x\\clearcase_find_change.cmd $v_drive $v_path $v_label \n"
 set v_outp [exec cmd << $v_cmd]

当我从命令行启动批处理文件时,它可以工作并将命中写入日志文件,但是当我从 Tcl 启动它时,我在命令窗口中看到命中,但它只创建没有内容的日志文件。我已经使用一个非常简单的批处理文件对其进行了测试,该文件仅包含 echo 命令和重定向。这很有效,我也尝试过使用不同的驱动器,但没有成功。我还检查了批处理文件收到的参数,但对我来说一切看起来都很好。

简单的调用,有效:

Batch: echo %1 > Y:\x\%2.log
Tcl: set v_cmd "y:\\x\\simple_echo.cmd $v_lib $v_label \n"

it's me again ;-)

I try to start the cleartool find command from a batch file. That batch files gets his arguments from a Tcl script.

Batch File:

 SET VERARG="version(\main\LATEST) && !lbtype(%3)"
 cleartool find . -version %VERARG% -print > Y:\x\Logs\%3.log

Tcl Script:

 set v_cmd "y:\\x\\clearcase_find_change.cmd $v_drive $v_path $v_label \n"
 set v_outp [exec cmd << $v_cmd]

When I start the batch file from command line, it works and it wrotes the hits to the log-file, but when I start it from Tcl, I see the hits in the command window, but it only creates the log-files with no content. I tested it already with a very simple batch file, which only contents a echo command and a redirection. That worked, I've also tried to use different drives, but with no success. I checked also the received arguments of the batch-file, but everything looked fine to me.

Simple Call, which worked:

Batch: echo %1 > Y:\x\%2.log
Tcl: set v_cmd "y:\\x\\simple_echo.cmd $v_lib $v_label \n"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

陌伤浅笑 2024-12-04 10:49:54

也许缺少一个 cmd 指令来指定 DOS 会话应执行然后退出

set v_outp [exec cmd << $v_cmd /c]

或:

set v_outp [exec cmd /c << $v_cmd]

或:(

set v_cmd "/c y:\\x\\clearcase_find_change.cmd $v_drive $v_path $v_label \n"
set v_outp [exec cmd << $v_cmd]

以确保首先传递 /c

请参阅 < a href="http://www.faqs.org/faqs/tcl-faq/tk/windows/" rel="nofollow">Tcl/Tk 常见问题解答:

exec cmd.exe >&@stdout <@stdin /c dir      

将对当前目录执行目录命令。
查看 Windows 帮助,了解 cmd.exe 下可用的开关。
/c”告诉它执行命令然后退出。 “/k”告诉它执行命令并保持 DOS 命令解释器处于活动状态。
(请注意,cmd.exe 是 Windows NT 上 MS-DOS 解释器的名称。)

Maybe it is missing a cmd directive to specify that the DOS session should execute and then quit:

set v_outp [exec cmd << $v_cmd /c]

or:

set v_outp [exec cmd /c << $v_cmd]

or:

set v_cmd "/c y:\\x\\clearcase_find_change.cmd $v_drive $v_path $v_label \n"
set v_outp [exec cmd << $v_cmd]

(to make sure the /c is passed first)

See Tcl/Tk FAQ:

exec cmd.exe >&@stdout <@stdin /c dir      

will do the directory command for the current directory.
Check out the Windows help for the switches available under cmd.exe.
"/c" tells it to execute the command and then exit. "/k" tells it to execute the command and keep the DOS command interpreter active.
(Note that cmd.exe is the name of the MS-DOS interpreter on Windows NT.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文