Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

HI, I am trying to write a script in Perl which will create a clearcase view (dynamic) and also set the config spec from a file. But when i run the script, it terminates just after creating the view and not proceeding with further commands (Probably because of a new shell). Can you please help me in fixing this. My code is mentioned below

#!/opt/trs/apps/bin/perl -w use strict; my $usr=`whoami`; print " User is $usr "; my $ct = '/usr/atria/bin/cleartool'; chomp($usr); #my $viewtag = $usr."-pal-rel"; my $viewtag="palmida-rel"; my $bl_name = $ARGV[0]; my $cs_file = "/tmp/$usr-cc-cs.txt"; print " the BL is $bl_name \n"; open (my $file, ">", "$cs_file") || die ("No Config Spec file"); #print MYFILE "element * CHECKEDOUT \nelement * /main/LATEST"; print $file "element * $bl_name \n"; close ($file); print $file; sub usage { print " USAGE: \n Please Run the script as shown below. \n perl /home +/venn/MyPerl/pal.pl <BL NAME> \n"; } #&usage(); print " $viewtag \n"; #system(sprintf("%s mkview -tag %s -stgloc viewstg_bheecc18; %s setvie +w %s", $ct, $viewtag, $ct, $viewtag)); #system ("$ct mkview -tag $viewtag -stgloc viewstg_bheecc18; $ct setvi +ew $viewtag; $ct catcs"); system ("$ct mkview -tag $viewtag -stgloc viewstg_bheecc18;"); system ("$ct setview $viewtag; $ct setcs $cs_file"); system ("$ct setview $viewtag; $ct catcs");
My Apologies if i am posting this in the wrong forum/section. Regards, Perl Noob !.. Venu

Replies are listed 'Best First'.
Re: Execute multiple clearcase commands in Perl Script
by Athanasius (Archbishop) on Oct 08, 2013 at 13:36 UTC

    From system:

    ...a fork is done first and the parent process waits for the child process to exit.

    So if the first system call invokes (say) an interactive process, nothing more will happen in the Perl script until the interactive process is terminated by the user. If this is the problem, you need to invoke the ClearCase view using fork or threads rather than system.

    Hope that helps,

    Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,