Home > Archive > PERL Miscellaneous > December 2006 > Using clearcase command in perl script
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Using clearcase command in perl script
|
|
| mnt006@gmail.com 2006-12-26, 7:05 pm |
| 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.
| |
| Paul Lalli 2006-12-26, 7:05 pm |
| mnt...@gmail.com 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
| |
| mnt006@gmail.com 2006-12-26, 7:05 pm |
| 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:
> mnt...@gmail.com wrote:
>
>
> Please type real code, even in examples.
>
> my @array = qw(/vobs/abc /vobs/abc/foo1.c /vobs/abc/foo2.c);
>
>
> 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
| |
| Paul Lalli 2006-12-26, 7:05 pm |
| mnt006@gmail.com wrote:
> 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
| |
| Andrew DeFaria 2006-12-27, 7:01 pm |
| mnt006@gmail.com 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" 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.
|
|
|
|
|