Thanks for the detailed reply! Before this sample script, I actually thought that your idea was bad because every type of shell or operating system has its own way of redirecting the standard error -- but you proved me wrong (or is it Perl that always launches the same type of shell when it runs backticks, and this is why it works?). I really didn't know that this error redirection is uniform in all shells and operating systems. (At least those we use, Linux and Windows with several shells in each.) I was surprised to see that this worked on both "cmd" on Windows, and on "tcsh" and "bash" on Linux. Thanks! Shlomo
-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Monday, June 24, 2002 4:51 PM To: [EMAIL PROTECTED]; [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: RE: How to find out the CVSROOT and location in the repository of a w orking directory Shlomo, If the "CVS internals" change for CVS/Root and CVS/Repository many people would be changing scripts. The global "-t" tag suggestion could be used. You are correct that the output goes to STDERR but you could redirect STDERR to STDOUT (2>&1) as shown in this example program: ---------------------------------------------------------------------------- -------------------------- #!/usr/local/bin/perl -w $file = "no_such_file"; #use non existing file @result = `cvs -t status $file 2>&1`; print "DEBUG1: \@result=\n @result\n"; ($cvsroot) = grep { s/.*main loop with CVSROOT=(.*)/$1/ } @result; print "DEBUG2: \$cvsroot=\n$cvsroot\n"; $cvsroot =~ s/^.*:(.*)$/$1/; # remove any pserver stuff print "DEBUG3: \$cvsroot=\n$cvsroot\n"; ---------------------------------------------------------------------------- -------------------------- I tested the above and got the output below.(note I changed the actual IP address shown) Using a non existing file makes the program run quickly. miller@cmp:/home/miller/cvs_stage/cm_tools: testit DEBUG1: @result= -> main loop with CVSROOT=:pserver:miller@cmp:/sdhs_mnt2/cvsroot -> Connecting to cmp(123.123.123.123):2401 cvs server: nothing known about no_such_file =================================================================== File: no file no_such_file Status: Unknown Working revision: No entry for no_such_file Repository revision: No revision control file DEBUG2: $cvsroot= :pserver:miller@cmp:/sdhs_mnt2/cvsroot DEBUG3: $cvsroot= /sdhs_mnt2/cvsroot Dale Miller > -----Original Message----- > From: Reinstein, Shlomo [mailto:[EMAIL PROTECTED]] > Sent: Monday, June 24, 2002 7:35 AM > To: '[EMAIL PROTECTED]'; Reinstein, Shlomo; [EMAIL PROTECTED] > Subject: RE: How to find out the CVSROOT and location in the > repository of a w orking directory > > > Hi, > In my question, I was referring ONLY to the CVSROOT (and repository > location) of a working directory. Inside a working directory, the > information is stored in the CVS/Root and CVS/Repository > files, and the > CVSROOT environment variable is not at all interesting (because it is > overriden by the CVS/Root file). > Like I said, I could read the CVS/Root file, but I consider > this file to be > "CVS internals", and thus reading it is not a clean solution > (that is, I > would have to change my script if the implementation of CVS > changed and this > file was renamed, for example). > I got another answer that said to run "cvs -t status" (use > the global "-t" > option). The problem with this, as far as I'm concerned, is > that the CVSROOT > information from the "-t" option goes to the standard error, > rather than the > standard output. > Thanks, > Shlomo > > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] > Sent: Monday, June 24, 2002 3:27 PM > To: [EMAIL PROTECTED]; [EMAIL PROTECTED] > Subject: RE: How to find out the CVSROOT and location in the > repository > of a w orking directory > > > Shlomo, > > You could have your perl program check the environment for > CVSROOT as shown > here: > > my $CVSROOT = "$ENV{'CVSROOT'}"; > if ($CVSROOT eq "") { > print "CVSROOT is not defined - aborting\n"; > exit 1; > } > > If you are using pserver you could remove the pserver > information using: > $CVSROOT =~ s/^.*:(.*)$/$1/; # remove any pserver stuff > > You could also check the CVS/Root file at the first directory > in a work > area. The content of it should match CVSROOT. > > Dale Miller > > > > -----Original Message----- > > From: Reinstein, Shlomo [mailto:[EMAIL PROTECTED]] > > Sent: Sunday, June 23, 2002 9:11 AM > > To: '[EMAIL PROTECTED]' > > Subject: How to find out the CVSROOT and location in the > > repository of a w orking directory > > > > > > Hi, > > > > Is there a "clean" way to find out what is the CVSROOT of a working > > directory and where in the repository it is located? I need > > to find that out > > from within a Perl script, and by "clean" I mean that I > > prefer not to look > > into the CVS/Root and CVS/Repository files, because I > > consider them to be > > CVS internals that might change some day. > > I know that using "cvs status" I can find out the whole > > repository path, but > > there is no separation between the CVSROOT and the location > inside the > > repository. > > > > To be more specific about what I need (maybe there's a way to > > do it without > > caring for the CVSROOT and location), I have a file in each > > module that has > > a fixed name and is used by my script to enable users to > > "lock" the module > > for a short time. Whenever a new branch is created for a > > module, this file > > should be "initialized" for that branch, to indicate that the > > branch is "not > > locked". To do this, the script should modify it and commit a > > new revision > > of it into the branch. (This is needed because the file > might indicate > > "locked" state for the root of the branch.) In order to do > > this, I want to > > check-out a fresh copy of that file (okay, with its whole > > directory) to a > > temporary directory, and then do these things on the copy in > > the temporary > > directory. In order to check it out, I need the CVSROOT and > > location within > > the repository. > > > > Thanks, > > Shlomo > > > > > > > > _______________________________________________ > > Info-cvs mailing list > > [EMAIL PROTECTED] > > http://mail.gnu.org/mailman/listinfo/info-cvs > > > _______________________________________________ Info-cvs mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/info-cvs _______________________________________________ Info-cvs mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/info-cvs
