Using clearcase command in perl script

M

mnt006

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.
 
P

Paul Lalli

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
 
M

mnt006

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 said:
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
 
P

Paul Lalli

Actual command would look file following

"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
 
A

Andrew DeFaria

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" 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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top