Filehandle Pipe Problem?

G

g4173c

Hi:

I have the following code for checking if a file is all ready
checked out for editing. It works if the file is checked out, however
if the file isn't checked out the pipe is closed and I never go into
the while loop. Any ideas what I should change to get this to work?

sub CC_ChkOut {
my $ccfile = shift (@_);
#
# Check to see if the file is all ready checked out, if not check it
out unreserved.
#
open (CC, "cleartool lsco -me $ccfile |") or die "Error: Problem
with check file status: $!\n";
while (<CC>) {
if (/checkout/) {
print "All ready checked out...\n";
}
else {
system ("cleartool co -unr -nc $ccfile") == 0 || die
"Error: Couldn't Check Out $ccfile: $!\n";
}
}
}

Thanks in advance for any help!!
Tom
 
G

g4173c

D'oh!

sub CC_ChkOut {
my $ccfile = shift (@_);
#
# Check to see if the file is all ready checked out, if not check it
out unreserved.
#
open (CC, "cleartool lsco -me $ccfile |") or die "Error: Problem
with check file status: $!\n";
if (eof(CC)) {
system ("cleartool co -unr -nc $ccfile") == 0 || die "Error:
Couldn't Check Out $ccfile: $!\n";
}
else {
print "All ready checked out...\n";
}
close (CC);
}
 
X

xhoster

D'oh!

sub CC_ChkOut {
my $ccfile = shift (@_);
#
# Check to see if the file is all ready checked out, if not check it
out unreserved.
#
open (CC, "cleartool lsco -me $ccfile |") or die "Error: Problem
with check file status: $!\n";
if (eof(CC)) {
system ("cleartool co -unr -nc $ccfile") == 0 || die "Error:
Couldn't Check Out $ccfile: $!\n";
}
else {
print "All ready checked out...\n";
}
close (CC);
}

Isn't that race condition? I'm not familiar with cleartool, but it seems
like there should a way to issue a single command which will combine
both functionalities atomically. It it is not already checked out, check
it out unreserved. Otherwise, report the error.

Xho
 

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,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top