Jon,
The system call always returns the execution status (i.e., 0 for success,
return code * 256 for other than success). What you want is to use the
back-tick or qw() call:
$Output = `$cmd`;
I would also prefer the use of the string matching capability, especially
since != is for numeric comparisons. Something like:
if ( $Output =~ /inspected/ )
{ # code to handle inspected being present }
else
{ # code to handle inspected not present }
You might also want to get into the habit of using chomp() when you are
about to handle a string returned from a system call. It benignly removes
<CR> and <LF> characters that mark the end of a line. HTH.
Ted
______________
T. J. Jardine (Ted)
Sr. SCM Administrator
Aspen Technology, Inc.
19204 North Creek Parkway, #104
Bothell, WA 98011 USA Avocation:
Voice: 1.425.492.2272 Flight Instructor,
FAX: 1.425.492.2125 Airplanes & Instruments
E-mail: mailto:ted.jardine@aspentech.com "Keep the pointy end forward,
URL: http://www.aspentech.com the dirty side down."
-----Original Message-----
From: Shanks, Jon [mailto:jshanks@logicon.com
Sent: Friday, January 28, 2000 15:50
To: CCIUG (E-mail)
Subject: [cciug] Perl Help (a new problem)
Hello all,
I have been working on putting something in place here for a few days now. I
had a previous related issue called "Trigger help needed". Wolfgang Laun got
me on the path I needed to be on, but now I need help with the specific
syntax in Perl.
Basically what I am trying to do (which was my original issue) is have a
trigger that fires upon checkin for all files. The corresponding script
would check the attribute value on the file. If the attribute is set to
"inspected" then the script would return 1 so that the checkin would fail.
He is the script so far
$ACCEPT=0;
$REJECT=1;
$CLEARCASE_PN = $ENV{ "CLEARCASE_PN" } . '@@';
$cmd="cleartool describe -s -aattr Status $CLEARCASE_PN";
print STDERR $cmd , "\n\n";
if (system($cmd) != "\"inspected\"") {
print STDERR "Accepted\n";
exit $ACCEPT;
}
else {
print STDERR "Rejected\n";
exit $REJECT;
}
The "$CLEARCASE_PN = $ENV{ "CLEARCASE_PN" } . '@@';" line get me the file
name with the @@ at the end (I couldn't find an EV that would give me this)
which is needed to check for an attribute set on the element instead of on a
version.
My problem is that the system($cmd) call doesn't return the actual attribute
value. When I check that value I get 0 no matter if the attribute is set on
the file or not. How do I go about getting the actual attribute value
returned so that my if statement will work? Is there a better way? Please
help.
Thanks!
~~~~~~~~~~~~~~~~~~~~~~~
Jon Shanks
Sr. CM Analyst
Logicon Advanced Technology
Colorado Springs, CO
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
This archive was generated by hypermail 2b29 : Sun May 06 2001 - 00:22:41 EDT