1

I am trying to run the following code, but the got #error 1 at startview command, and #error 2 in desc command.

    use Win32::OLE; 
    $ct = Win32::OLE->new('ClearCase.ClearTool') or die "Could not create ClearTool object\n";  
    $view = "ccadm01_UARK_DEV";
    $output = $ct->CmdExec("pwv") or die("Cleartool returned error: ", Win32::OLE->LastError(), "\n"); 
    print ("pwv \$output = $output\n");

# error 1 : cleartool return error 0   
    $output = $ct->CmdExec("startview ccadm01_UARK_DEV") or die("Cleartool returned error: ", Win32::OLE->LastError(), "\n"); 

    $CWD = $view_dir;  
    print( "Current directory: $CWD\n");

# error 2: No view context available
    $output = $ct->CmdExec("describe -fmt \"%[versions]Cp\" activity:USR0200004985\@\\Unix_PVOB") or die("Cleartool returned error: ", Win32::OLE->LastError(), "\n"); 
    print ("desc \$output = $output\n");

For #error 1, I tried the same command from DOS, it works.

Jirong Hu
  • 2,315
  • 8
  • 40
  • 63

1 Answers1

0

You need to make sure your $view is a valid dynamic view tag for cleartool startview to work.
(make sure to not use cleartool setview, as it spawns a subshell)

Also if it returns error 0, you can assume it has worked: CAL might return an "error", but status 0 should mean the command has been executed.

An error different from 0, though, means something went wrong.

And you need to cd into that view (/view/<viewTag> or m:\<viewTag>) for a cleartool descr to work.
That one, executed in the wrong folder, is supposed to fail, hence "error 2".


The OP Jirong Hu points in the comments to Using Perl with Rational ClearCase Automation Library (CAL) and this script as an example.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • I even changed to $ct->CmdExec("startview ccadm01_UARK_DEV") , still the same error, the view tag is right and same command can be run from command line cleartool. the 2nd command I use $CWD = $view_dir; to cd into the view, because the backticks doesn't work too. Is this CAL still supported in CCCQ v8? – Jirong Hu Feb 06 '16 at 15:35
  • @Jir try also a pwv, to check where you are. Also, before your startview, make sure the view is stopped, just to check if the CAL startview is working. – VonC Feb 06 '16 at 15:41
  • pwc output in None. cleartool startview can run multiple time even it's started. I always run this just to make sure. Oh, I was wrong about command line, it fails from DOC command line too, code and output shown as below: I put it into answer. – Jirong Hu Feb 06 '16 at 16:07
  • @JirongHu do not put it as an answer. Answers are for answers only. Edit your question ;) – VonC Feb 06 '16 at 16:31
  • @JirongHu in your second `CAL` command (the '`describe` call one), could you try `cd m:\ccadm01_UARK_DEV && describe -fmt ...` – VonC Feb 06 '16 at 16:33
  • thanks for telling me I shall edit the original question. Anyway, it didn't work so I changed to using this way, problem resolved. http://www.ibm.com/developerworks/rational/library/4711.html. Thanks a lot for your time, during the weekend! – Jirong Hu Feb 06 '16 at 17:37
  • @JirongHu Great. I have included a link to that article in the answer for more visibility. – VonC Feb 06 '16 at 18:17