2 ################################################################################
6 # Description: This script is a test client for cqd.
7 # Author: Andrew@DeFaria.com
8 # Created: Fri May 31 15:34:50 2002
9 # Modified: 2007/05/17 07:45:48
12 # (c) Copyright 2007, ClearSCM, Inc. , all rights reserved.
14 ################################################################################
18 # Add the appropriate path to our modules to @INC array. We use ipconfig to
19 # get the current host's IP address then determine whether we are in the US
21 my @ipconfig = grep (/IP Address/, `ipconfig`);
22 my ($ipaddr) = ($ipconfig[0] =~ /(\d{1,3}\.\d{1,3}.\d{1,3}\.\d{1,3})/);
24 # US is in the subnets of 192 and 172 while China is in the subnet of 10
25 if ($ipaddr =~ /^192|^172/) {
26 unshift (@INC, "//sons-clearcase/Views/official/Tools/lib");
27 } elsif ($ipaddr =~ /^10/) {
28 unshift (@INC, "//sons-cc/Views/official/Tools/lib");
30 die "Internal Error: Unable to find our modules!\n"
42 my $servername = $ENV {CQDSERVER};
48 print "Usage: cqc [ -s servername ] bugid [ fieldname... ]\n";
58 if ($ARGV [0] && $ARGV [0] eq "-s") {
63 $servername = shift (@ARGV);
68 $bugid = shift (@ARGV);
71 @query_fields = @ARGV;
73 # Downshift any query_fields
74 foreach (@query_fields) {
75 $query_fields [$i++] = lc $_;
82 if ($bugid =~ /^\d+$/) {
83 if (length ($bugid) < 13) {
84 $len = 13 - length ($bugid);
86 # Can't even prepend "BUGS2"!
87 print "Invalid bug id \"$bugid\" encountered!\n";
90 $bugid = "BUGS2" . "0" x ($len - 5) . $bugid;
101 if (defined ($servername)) {
102 die "Unable to connect to $servername\n" if cqc::Connect ($servername) < 0;
106 $result = cqc::GetBugRecord (fix_bugid ($bugid), %fields);
107 die "Unable to connect to server\n" if $result < 0;
109 print "Bug ID $bugid was not found\n";
112 foreach (@query_fields) {
113 if (@query_fields > 1) {
114 print "$_: $cqc::fields{$_}\n";
116 print "$cqc::fields{$_}\n";
120 while (($key, $value) = each (%fields)) {
121 $value =~ s/\r/\r\n/g;
122 print "$key: $value\n";
127 print "Enter bug ID:";
129 while ($command = <STDIN>) {
131 last if $command =~ m/exit|quit|shutdown/;
133 $bugid = fix_bugid ($command);
134 $result = cqc::GetBugRecord ($bugid, %fields);
135 die "Unable to connect to server\n" if $result < 0;
137 print "Bug ID $bugid was not found\n";
139 while (($key, $value) = each (%fields)) {
140 $value =~ s/\r/\r\n/g;
141 print "$key: $value\n";
145 print "Enter bug ID:";