2 ################################################################################
4 # File: cqc: Clearquest client
5 # Description: This script is a test client for cqd.
6 # Author: Andrew@DeFaria.com
7 # Created: Fri May 31 15:34:50 2002
11 # (c) Copyright 2002, Salira Optical Network Systems, all rights reserved.
13 ################################################################################
17 # Add the appropriate path to our modules to @INC array. We use ipconfig to
18 # get the current host's IP address then determine whether we are in the US
20 my @ipconfig = grep (/IP Address/, `ipconfig`);
21 my ($ipaddr) = ($ipconfig[0] =~ /(\d{1,3}\.\d{1,3}.\d{1,3}\.\d{1,3})/);
23 # US is in the subnets of 192 and 172 while China is in the subnet of 10
24 if ($ipaddr =~ /^192|^172/) {
25 unshift (@INC, "//sons-clearcase/Views/official/Tools/lib");
26 } elsif ($ipaddr =~ /^10/) {
27 unshift (@INC, "//sons-cc/Views/official/Tools/lib");
29 die "Internal Error: Unable to find our modules!\n"
41 my $servername = $ENV {CQDSERVER};
47 print "Usage: cqc [ -s servername ] bugid [ fieldname... ]\n";
57 if ($ARGV [0] && $ARGV [0] eq "-s") {
62 $servername = shift (@ARGV);
67 $bugid = shift (@ARGV);
70 @query_fields = @ARGV;
72 # Downshift any query_fields
73 foreach (@query_fields) {
74 $query_fields [$i++] = lc $_;
81 if ($bugid =~ /^\d+$/) {
82 if (length ($bugid) < 13) {
83 $len = 13 - length ($bugid);
85 # Can't even prepend "BUGS2"!
86 print "Invalid bug id \"$bugid\" encountered!\n";
89 $bugid = "BUGS2" . "0" x ($len - 5) . $bugid;
100 if (defined ($servername)) {
101 die "Unable to connect to $servername\n" if cqc::Connect ($servername) < 0;
105 $result = cqc::GetBugRecord (fix_bugid ($bugid), %fields);
106 die "Unable to connect to server\n" if $result < 0;
108 print "Bug ID $bugid was not found\n";
111 foreach (@query_fields) {
112 if (@query_fields > 1) {
113 print "$_: $cqc::fields{$_}\n";
115 print "$cqc::fields{$_}\n";
119 while (($key, $value) = each (%fields)) {
120 $value =~ s/\r/\r\n/g;
121 print "$key: $value\n";
126 print "Enter bug ID:";
128 while ($command = <STDIN>) {
130 last if $command =~ m/exit|quit|shutdown/;
132 $bugid = fix_bugid ($command);
133 $result = cqc::GetBugRecord ($bugid, %fields);
134 die "Unable to connect to server\n" if $result < 0;
136 print "Bug ID $bugid was not found\n";
138 while (($key, $value) = each (%fields)) {
139 $value =~ s/\r/\r\n/g;
140 print "$key: $value\n";
144 print "Enter bug ID:";