Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Using clearcase command in perl script

Reply
Thread Tools

Using clearcase command in perl script

 
 
mnt006@gmail.com
Guest
Posts: n/a
 
      12-26-2006
Hi,
I am having list of files in an array. Example.
array[0]=/vobs/abc
array[1]=/vobs/abc/foo1.c
array[2]=/vobs/abc/foo2.c
........

I want to perform clearcase check out command on this list of files.
Can anyone suggest how to do this using perl?

Thanks.

 
Reply With Quote
 
 
 
 
Paul Lalli
Guest
Posts: n/a
 
      12-26-2006
(E-Mail Removed) wrote:

> I am having list of files in an array. Example.
> array[0]=/vobs/abc
> array[1]=/vobs/abc/foo1.c
> array[2]=/vobs/abc/foo2.c


Please type real code, even in examples.

my @array = qw(/vobs/abc /vobs/abc/foo1.c /vobs/abc/foo2.c);

> I want to perform clearcase check out command on this list of files.
> Can anyone suggest how to do this using perl?


Perhaps you could describe how a "clearcase check out command" works or
at least looks? Is it something that can only accept one filename as
the argument? In that case, do something like:
foreach my $file (@array) {
system("clearcase_checkout_command", $file);
}

Is it something that accepts multiple file names, all specified on the
command line? Then do something like:
system("clearcase_checkout_command", @array);

Until you tell us how to do the basic task, it's rather difficult to
help you modify it for the real pursuit...

Paul Lalli

 
Reply With Quote
 
 
 
 
mnt006@gmail.com
Guest
Posts: n/a
 
      12-26-2006
Thanks for responding.
Cleartool makebranch command creates branch and checks out the file.
It does take multiple files as input via command line.

Actual command would look file following
> cleartool mkbranch -nc my_branch_name /vobs/abc/foo1.c /vobs/abc/foo2.c


"cleartool mkbranch -nc my_branch_name" would be constant string for
all the files which are needed to be checked out.

So from your suggestion I did try something like following.

system("cleartool mkbranch -nc my_branch_name", @array);

But due to some reason branch wasn't created.

Thanks,

Paul Lalli wrote:
> (E-Mail Removed) wrote:
>
> > I am having list of files in an array. Example.
> > array[0]=/vobs/abc
> > array[1]=/vobs/abc/foo1.c
> > array[2]=/vobs/abc/foo2.c

>
> Please type real code, even in examples.
>
> my @array = qw(/vobs/abc /vobs/abc/foo1.c /vobs/abc/foo2.c);
>
> > I want to perform clearcase check out command on this list of files.
> > Can anyone suggest how to do this using perl?

>
> Perhaps you could describe how a "clearcase check out command" works or
> at least looks? Is it something that can only accept one filename as
> the argument? In that case, do something like:
> foreach my $file (@array) {
> system("clearcase_checkout_command", $file);
> }
>
> Is it something that accepts multiple file names, all specified on the
> command line? Then do something like:
> system("clearcase_checkout_command", @array);
>
> Until you tell us how to do the basic task, it's rather difficult to
> help you modify it for the real pursuit...
>
> Paul Lalli


 
Reply With Quote
 
Paul Lalli
Guest
Posts: n/a
 
      12-26-2006
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:

> Actual command would look file following
> > cleartool mkbranch -nc my_branch_name /vobs/abc/foo1.c /vobs/abc/foo2.c

>
> "cleartool mkbranch -nc my_branch_name" would be constant string for
> all the files which are needed to be checked out.
>
> So from your suggestion I did try something like following.
>
> system("cleartool mkbranch -nc my_branch_name", @array);
>
> But due to some reason branch wasn't created.


"some reason"? Did you bother checking any of the error statuses? Did
you check the return value of system()? The value of $? ? The value
of $! ?

Have you read the documentation for the function you're using? perldoc
-f system

system("cleartool", "mkbranch", "-nc", "my_branch_name", @array);
will most likely produce better results. Read the aforementioned
documentation to discover why.

Paul Lalli

 
Reply With Quote
 
Andrew DeFaria
Guest
Posts: n/a
 
      12-27-2006
(E-Mail Removed) wrote:
> Thanks for responding. Cleartool makebranch command creates branch and
> checks out the file. It does take multiple files as input via command
> line.
>
> Actual command would look file following
>> cleartool mkbranch -nc my_branch_name /vobs/abc/foo1.c /vobs/abc/foo2.c

> "cleartool mkbranch -nc my_branch_name" would be constant string for
> all the files which are needed to be checked out.
>
> So from your suggestion I did try something like following.
>
> system("cleartool mkbranch -nc my_branch_name", @array);
>
> But due to some reason branch wasn't created.

You do realize you initially asked "How to I checkout files" not "How do
I call cleartool mkbranch" don't you?

How about this:

my $cmd = "cleartool mkbranch -nc my_branch_name" . @array;
system $cmd

Then run the script in the debugger and stop at the system command and
"p $cmd" to see what exactly is in $cmd. Then copy and paste that to a
command line thus executing the command outside of perl and seeing
exactly what it did or did not do.

Personally I tend to:

my $cmd = "whatever command I'm doing";
my @output = `$cmd 2>&1`;
my $status = $?;
chomp @output;

if ($status ne 0) {
<print some sort of error message like perhaps the contains of
@output>
}

This way I can examine what $cmd contains before it's executed, get the
command line output including stderr, get the status so I can check it
and act accordingly if the status says the command failed.
--
Andrew DeFaria <http://defaria.com>
Demons are a Ghouls best Friend.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to use clearcase commands in perl script sunil Perl Misc 5 01-18-2007 02:28 PM
Using Perl to check-out check-in in Clearcase mihirtr@gmail.com Perl Misc 0 12-22-2006 07:20 PM
ClearCase 05.00 using ClearCase::CtCmd::exec crash perl 5.8.3 Maverick Ieong Perl Misc 1 11-24-2004 10:32 PM
perl get crash when using ClearCase::CtCmd::exec Maverick Ieong Perl Misc 2 11-18-2004 06:01 PM
Using File::Copy with ClearCase Views Tony George Perl 1 11-14-2003 05:17 PM



Advertisments