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
.
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
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 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:
/vobs/xxx
refers to the right vob in the right view/vobs
.Trying to do all in one step will mostly fail due to the sub-shell launched by setview.