Beefy Boxes and Bandwidth Generously Provided by pair Networks DiBona
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Cleartool_Copy

by sierrathedog04 (Hermit)
on Sep 05, 2001 at 00:43 UTC ( #110156=snippet: print w/ replies, xml ) Need Help??

Description: A script to checkout, modify and checkin a file that is in the Clearcase version control system. The file must already exist in its changed form externally. Specify source and target parameters and the program will move the changed file into the target directory of the Clearcase view.
# sierrathedog04, jonathansamuel@yahoo.com  
# program to automatically checkout and checkin files for 
# the Clearcase version control system.
# From the command line enter as the parameters specified 
# below. It will take the file $checkOutFile from the 
# directory $sourceDirand copy it in to the directory 
# $targetDir in the Clearcase view $viewName.

# This program will generate an error message unless the 
# specified file already exists in both the directory 
# $targetDir and the directory$sourceDir. The two versions
# of the file must differ.

use strict;
use FileHandle;

my $viewName = shift;  # name of Clearcase view.
my $targetDir = shift; # name of directory in the Clearcase
# view
# which will contain the file after it is checked in
my $checkOutFile = shift; # name of file to check out and 
# then in again.
my $sourceDir = shift; #current location of file to check in
my $homeDir = $ENV{HOME};
unless ( $viewName && $targetDir && $checkOutFile && $sourceDir ) {
        die "This subroutine takes four parameters: \n the first of wh
+ich is $viewName.\n The second of which is $targetDir.\n The third of
+ which is $checkOutFile.\n The fourth of which is $sourceDir.\n  The 
+first parameter is the name of the Clearcase view.\n The second param
+eter is the name of the view directory \nfor which all files will be 
+checked in and checked out.\n The third parameter is t
he name of the file to be checked out and in.\n The fourth parameter i
+s the name of the directory in \nwhich the most recent copies of the 
+files exist. \n";
}
my $fh = new FileHandle "> $homeDir/ctscript.txt";
defined $fh || die "unable to open temporary filehandle for creating e
+xecutable
script\n";
ctrun("setview $viewName");
ctrun("cd $targetDir");
ctrun("co -nc $checkOutFile");
ctrun("sh cp $sourceDir/$checkOutFile $targetDir/$checkOutFile");
ctrun("ci -nc $checkOutFile");
sub ctrun {
        my $command = shift;
        print $fh "$command\n";
}
$fh->close;

my $pid = open(PH,"cleartool < $homeDir/ctscript.txt 2>&1 |");

while (<PH>) {
        print "$_ \n";
        die "Unable to open view $viewName. Please make certain that t
+his view exists.\n" if (/View tag not found/);
        die "Unable to find the $targetDir directory in the VOB. Pleas
+e make certain that you have specified it correctly.\n" if (/Unable t
+o change directory to
/);
        die "You have attempted to check out file $checkOutFile in the
+ $targetDir directory in the VOB. Please make certain that this file 
+exists in the VOB.\n"
 if (/Unable to access/ || /Not a vob object/);
        if (/data identical to predecessor/){
                print "The version of $checkOutFile that you are attem
+pting to check in from $sourceDir to $targetDir is identical to what 
+was there before. Cle
arcase does not permit the checking in of files unless they have been 
+modified in some way from their previous version.\n $_ \nProcessing o
+f any additional files will continue.\n" ;
        die;
        }
        die "There has been an error while processing file $checkOutFi
+le into directory $targetDir. $_ \nProcessing of any additional files
+ will continue.\n" if
 (/Error/);
}
die "\n Completed checkout and checkin of files from $sourceDir\n into
+ the directory $targetDir\n in the view $viewName.\n";

Comment on Cleartool_Copy
Download Code
Re: Cleartool_Copy
by petral (Curate) on Sep 06, 2001 at 23:55 UTC
    You might try
    "ci -nc -ptime -keep -from $sourceDir/$checkOutFile $checkoutFile"
    That saves the call out to the shell to do the copy (and preserves the date of the original as the version's date.)

    Also, you might check out IPC::ClearTool. It opens a two-way pipe to the cleartool command and lets you send commands one at a time and check the error status on each step (and you don't need an intermediate file).

      p

Back to Snippets Section

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: snippet [id://110156]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (10)
As of 2014-04-17 10:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (443 votes), past polls