Filehandle Pipe Problem?

Discussion in 'Perl Misc' started by g4173c@motorola.com, Apr 20, 2007.

  1. Guest

    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
    , Apr 20, 2007
    #1
    1. Advertising

  2. Guest

    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);
    }
    , Apr 20, 2007
    #2
    1. Advertising

  3. Guest

    wrote:
    > 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

    --
    -------------------- http://NewsReader.Com/ --------------------
    Usenet Newsgroup Service $9.95/Month 30GB
    , Apr 20, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. lee, wonsun
    Replies:
    1
    Views:
    477
    Jack Klein
    Nov 2, 2004
  2. Wijaya Edward
    Replies:
    1
    Views:
    232
    Marc 'BlackJack' Rintsch
    Oct 26, 2006
  3. mathias

    filehandle to variable problem

    mathias, Jul 15, 2003, in forum: Perl Misc
    Replies:
    3
    Views:
    91
    mathias
    Jul 17, 2003
  4. Replies:
    1
    Views:
    214
    Ben Morrow
    Jun 2, 2004
  5. Replies:
    4
    Views:
    82
    Ted Zlatanov
    Jun 2, 2006
Loading...

Share This Page