gpt4 book ai didi

unix - 如何从 tcl 脚本运行 csh 脚本?

转载 作者:行者123 更新时间:2023-12-02 03:59:58 26 4
gpt4 key购买 nike

我正在尝试从 tcl 脚本运行 csh 脚本。

下面的 tcl 脚本调用 csh 脚本

#!/usr/bin/tclsh


set scripts_path /scratch/TCL_scripts/scripts_adders

set synthesis /scratch/TCL_scripts/synthesis.csh


set files [glob -directory $scripts_path *]
split $files
set files [lsort $files]
set i 1

foreach script $files {

puts "hello"
# puts [pwd]
exec /bin/csh -c $synthesis
puts $i

}

csh 文件(开头)如下:

#!/bin/csh -f


echo abcdefgh

当我仅从 unix 终端执行 csh 文件时,它工作正常。当我调用 Tcl 脚本时,它运行并确实写入“hello”并打印 i,但 csh 文件未执行,因为“abcdefgh”从未出现在终端中。我也尝试过其他命令,但总是遇到同样的问题:当我从 Tcl 脚本运行 csh 脚本时,它永远不会被执行,即使当我直接从终端运行它时它运行良好。

(我的 Tcl 脚本和 csh 脚本都是可执行的)

为了从 Tcl 脚本运行 csh 脚本,我必须做什么?

非常感谢

最佳答案

csh 脚本确实为您运行,但默认情况下,其标准输出成为 Tcl exec 命令的结果(如果它在标准错误上产生任何内容,这将成为 exec错误结果。要使输出和错误出现在终端上,您必须像这样修改 exec:

exec /bin/csh -c $synthesis >@stdout 2>@stderr

>@ 表示“将标准输出重定向到以下 channel ”(在本例中为 stdout),而 2>@ 则表示标准错误也是如此。

关于unix - 如何从 tcl 脚本运行 csh 脚本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13341427/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com