问题描述
我正在创建一个Perl脚本,除其他外,该脚本设置为ClearCase视图,提供环境并运行综合工具,最后对输出报告进行后处理。它是通过管道传输到使用 IPC :: open2
打开的shell进程来完成的。
I am creating a Perl script that, among other things, sets into a ClearCase view, sources an environment, and runs synthesis tools, and finally post-processes output reports. It does that by piping to a shell process opened using IPC::open2
.
如果我进入视图手动运行Perl脚本之前,它似乎可以正常工作(诸如 pwv
之类的cleartool子命令有效)。但是,当我在脚本中运行 $ ct setview anassar_ $ proj
时,它会显示以下错误消息:
If I set into the view manually before running the Perl script, it seems to work correctly (cleartool subcommands such as pwv
work). However, when I run the $ct setview anassar_$proj
in the script, it gives the following error message:
stty: standard input: Invalid argument
我不知道通过将其管道传输到Shell进程来禁止运行 ct setview
的任何约束。有帮助吗?
I am not aware of any constraints that prohibit running ct setview
by piping it to a shell process. Any help?
my ( $readme, $writeme );
# Open the default shell and hook to its stdin and stdout.
my $pid = open2( $readme, $writeme, "$ENV{SHELL}" ) or
croak "Cannot open IPC handles to $ENV{SHELL}\n";
runCmd("$ct pwv");
runCmd("$ct setview anassar_$proj");
runCmd("$ct pwv");
runCmd('source /vobs/blah/blah/blah/env.csh');
runCmd('echo env_var1 = $env_var1');
runCmd('echo env_var2 = $env_var2');
runCmd('echo env_var3 = $env_var3');
runCmd('exit'); # Exit from ClearCase View
runCmd('exit'); # Exit from shell.
sub runCmd {
my ( $cmd ) = @_;
my $sentinel = '___SOME_STRING_THAT_CANNOT_OCCUR_IN_OUTPUT___';
print $writeme "$cmd && echo $sentinel\n";
while ( my $output = <$readme> ) {
last if ( $output =~ /$sentinel/ );
print $output;
}
}
推荐答案
As我在回答中提到您看到的是,使用了通常不是一个好主意。
As I mention in the answer you saw "Python and ClearCase setview", using setview
in a script is generally not a good idea.
我知道的唯一解决方案是两个制作两个脚本:
The only solution I know is two make 2 scripts:
- 一个确保完成setview的操作,而
/ vobs / xxx
是指右视图中的右vob - 将使用
/ vobs
的一个。
- one which ensure that setview is done, and
/vobs/xxx
refers to the right vob in the right view - one which will use
/vobs
.
由于setview启动了子Shell,因此一步一步尝试全部失败。
Trying to do all in one step will mostly fail due to the sub-shell launched by setview.
这篇关于在使用Perl IPC :: open2打开的shell进程中无法“ cleartool setview”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!