我正在创建一个 Perl 脚本,其中包括设置为 ClearCase 视图、获取环境、运行综合工具,最后对输出报告进行后处理。它通过管道连接到使用IPC::open2
.
如果我在运行 Perl 脚本之前手动设置到视图中,它似乎可以正常工作(cleartool 子命令,例如pwv
work)。但是,当我$ct setview anassar_$proj
在脚本中运行时,它会给出以下错误消息:
stty: standard input: Invalid argument
我不知道ct setview
通过管道将其传输到 shell 进程来禁止运行的任何约束。有什么帮助吗?
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;
}
}