Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

ClearCase and Perl

by czach12345 (Initiate)
on Mar 06, 2014 at 18:42 UTC ( #1077269=perlquestion: print w/ replies, xml ) Need Help??
czach12345 has asked for the wisdom of the Perl Monks concerning the following question:

I have a Perl script that is trying to run a ClearCase script called "cleartool find" The issue is that is needs to be ran in a /../vob directory and not sure how to get the script to run in that directory.
#!/usr/bin/env perl use warnings; use strict; use Cwd; sub main() { stat("ls l-tr"); my %files; chdir ("/view/conflictcheck.view1/vobs/app_bos") or die "canno +t change: $!\n"; print(cwd); while (<>) { my ($branch, $count); chomp; $branch = $_; next if !$branch; print "Scanning $branch\n"; open(FILES, "cleartool find . -nxn -ele \"version(/mai +n/$branch/LATEST)\" -print |"); while (<FILES>) { chomp; push @{$files{$_}}, $branch; $count++; } close(FILES); if (!$count) { print "WARNING: $branch does not contain any files.\ +n" } } print "Calculating conflicts\n"; foreach my $file (keys %files) { my $len = @{$files{$file}}; next unless ($len > 1) && (-f $file); print "$file\n"; for (my $i = 0; $i < $len; $i++) { print " $files{$file}[$i]\n"; } } }

Comment on ClearCase and Perl
Download Code
Re: ClearCase and Perl
by GotToBTru (Curate) on Mar 06, 2014 at 19:35 UTC

    Can you edit your post to put in code tags? It makes it much, much easier to read. Viz.:

    use warnings; use strict; use Cwd; sub main() { my $foo = 'bar'; } main();

    versus

    use warnings; use strict; use Cwd; sub main() { $foo = 'bar'; } main();
      So here is the output as stated before that the script didnt get ran in the vobs directory.
      Scanning dev_BOS_kit_2013.12_B14.02 sh: /main/view/zac129.view1/vobs/app_bos/cleartool: No such file or di +rectory WARNING: dev_BOS_kit_2013.12_B14.02 does not contain any files. Scanning dev_BOS_kit_2014.01_B14.03_2014.01 sh: /main/view/zac129.view1/vobs/app_bos/cleartool: No such file or di +rectory WARNING: dev_BOS_kit_2014.01_B14.03_2014.01 does not contain any files +. And here is if I run it manually in the directory. Scanning dev_BOS_kit_2013.12_B14.02 Scanning dev_BOS_kit_2014.01_B14.03_2014.01 Calculating conflicts ./routines/websupport/WACDCashDisbursement2.MAC.xml dev_BOS_kit_2013.12_B14.02 dev_BOS_kit_2014.01_B14.03_2014.01 ./routines/Accounting/BACDR49.MAC.xml dev_BOS_kit_2013.12_B14.02 dev_BOS_kit_2014.01_B14.03_2014.01 ./classes/DB/DB.UTC.CusipSummary.CLS.xml dev_BOS_kit_2013.12_B14.02 dev_BOS_kit_2014.01_B14.03_2014.01 ./routines/websupport/WACDCashDisbursement.MAC.xml dev_BOS_kit_2013.12_B14.02 dev_BOS_kit_2014.01_B14.03_2014.01 ./routines/websupport/WLOPRCorrectRec.MAC.xml dev_BOS_kit_2013.12_B14.02 dev_BOS_kit_2014.01_B14.03_2014.01 ./classes/OCC/OCC.LOPR.Record.CLS.xml
        Thanks for the pointers. I have found that the directory is changing to the correct vobs directory to run the ClearCase script by checking the working directory before calling  open(FILES, "cleartool find . -nxn -ele \"version(/main/$branch/LATEST)\" -print |"); but the script still calls it from outside the vobs directory. Must be something to deal with the open command how I can calling the cleartool find script.
Re: ClearCase and Perl
by moritz (Cardinal) on Mar 06, 2014 at 20:13 UTC
    The issue is that is needs to be ran in a /../vob directory and not sure how to get the script to run in that directory.

    There's already a call to chdir in the script which changes the working directory; why not just adapt that to the correct path?

      Thanks for the reply. The chdir directory is the directory I need the ClearCase script to run in.
Re: ClearCase and Perl
by Laurent_R (Parson) on Mar 06, 2014 at 23:15 UTC
    Hmm, you speak about a "/../vob" directory and your script does a chdir to '"/view/conflictcheck.view1/vobs/app_bos"'. You have "vob" on the one hand and "vobs" on the other (Is it singular or plurial?). And, in addition, you chdir not to the vob or vobs directory, but to a subdirectory of "vobs". Could it be that this is the simple error barring you from running your script? Just my 2 cents...
      Yes it is vobs and the sub directory is where the files I need to run the cleartool find command. I get an output but as if it was ran outside of the vobs directory. Output with files can not be found. As if it can not find the files.
        What you have should work. It's unclear if the view "conflictcheck.view" was started and the vob was mounted when your script ran. If that were the case then it would seem like the vob was empty. How about doing the chdir then do an system('ls') to see if your script sees files after the chdir? It should. If not then the chdir failed (but you do error out if that happens). If there are no files then start another window and cd to that directory there. If the new shell window shows files but your script doesn't then there's something else wrong.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (8)
As of 2014-12-21 10:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (104 votes), past polls