• Home
  • Services
    • Consultancy
    • Custom Software Solutions
    • Systems Adminsitration
    • Web Applications
    • Customers
  • SCM
    • Clearcase
      • Triggers
      • Evil Twin Finder
      • GUI DiffBL
      • View Ager
      • Open Source Builds
    • Clearquest
      • Clearquest Daemon
      • DB Conversions
    • Git
      • Repository
  • Scripting
    • Perl
    • ECRDig
  • Sysadm
    • Environment
  • About
    • Services
    • Our People
    • Contact Us
 

ClearSCM Inc.

You are viewing an unstyled version of this page. Either your browser does not support Cascading Style Sheets (CSS) or CSS styling has been disabled.

ECRD Daemon

This is a client script that calls ecrd.

1 #!/usr/bin/perl
2 ################################################################################
3 #
4 # File:         ecrc: ECR client
5 # Description:  This script is a test client for ecrd.
6 # Author:       Andrew@DeFaria.com
7 # Created:      Tue Feb 15 11:01:24 PST 2005
8 # Modified:
9 # Language:     Perl
10 #
11 # (c) Copyright 2005, LynuxWorks, all rights reserved.
12 #
13 ################################################################################
14 use strict;
15 use warnings;
16 use File::Spec;
17
18 my ($me, $abs_path, $lib_path, $bin_path, $log_path);
19
20 BEGIN {
21   # Extract relative path and basename from script name.
22   $0 =~ /(.*)[\/\\](.*)/;
23
24   $abs_path     = (!defined $1) ? "." : File::Spec->rel2abs ($1);
25   $me           = (!defined $2) ? $0  : $2;
26   $me           =~ s/\.pl$//;
27
28   # Setup paths
29   $bin_path             = "$abs_path";
30   $lib_path             = "$abs_path/../lib";
31   $log_path             = "$abs_path/../log";
32
33   # Add the appropriate path to our modules to @INC array.
34   unshift (@INC, "$lib_path");
35 } # BEGIN
36
37 use ecrc;
38
39 # Global variables
40 my $servername          = (!defined $ENV {ECRDSERVER}) ? "lynx12" : $ENV {ECRDSERVER};
41 my $port                = (!defined $ENV {ECRDPORT})   ? 1500     : $ENV {ECRDPORT};
42 my $ecr                 = "";
43 my @query_fields        = ();
44 my $verbose;
45 my $debug;
46 my $key;
47 my $value;
48 my %fields;
49 my @ecrs;
50
51 sub Usage {
52   my $msg = shift;
53
54   print "ERROR: $msg\n\n" if defined $msg;
55
56   print "Usage: ecrc [-u] [-v] [-d] [ -s <server> ] [ -p <port> ] ";
57   print "ECR [ fieldname... ]\n";
58   print "\nWhere:\n\n";
59   print "\t-u:\t\tDisplay usage\n";
60   print "\t-v:\t\tTurn on verbose mode (Default off)\n";
61   print "\t-d:\t\tTurn on debug mode (Default off)\n";
62   print "\t-s:\t\tUse server named servername (Default lynx12)\n";
63   print "\t-s:\t\tUse port (Default 1500)\n";
64   print "\tECR:\t\tECR number to obtain info about\n";
65   print "\tfieldname:\tECR field names to retrieve info about (Default all)\n";
66
67   exit 1;
68 } # Usage
69
70 sub GetParms {
71   while ($ARGV [0]) {
72     if ($ARGV [0] eq "-v") {
73       $verbose          = 1;
74       ecrc::set_verbose;
75     } elsif ($ARGV [0] eq "-d") {
76       $debug            = 1;
77       ecrc::set_debug;
78     } elsif ($ARGV [0] eq "-u") {
79       Usage;
80     } elsif ($ARGV [0] eq "-p") {
81       shift @ARGV;
82       Usage "Port not specified" if !$ARGV [0];
83       $port = shift @ARGV;
84     } elsif ($ARGV [0] eq "-s") {
85       shift @ARGV;
86       Usage "Server name not specified" if !$ARGV [0];
87       $servername = shift @ARGV;
88     } else {
89       $ecr = shift (@ARGV);
90       last;
91     } # if
92     shift @ARGV;
93   } # while
94
95   @query_fields = @ARGV;
96
97   # Downshift any query_fields
98   my $i = 0;
99
100   foreach (@query_fields) {
101     $query_fields [$i++] = lc $_;
102   } # foreach
103 } # GetParms
104
105 # Main code
106 GetParms;
107
108 die "Unable to connect to $servername:$port\n" if !ecrc::Connect ($servername, $port);
109
110 if ($ecr) {
111   if ($ecr eq "\*") {
112     @ecrs = ecrc::GetECRRecord $ecr;
113
114     foreach (@ecrs) {
115       print "$_\n";
116     } # foreach
117
118     exit;
119   } # if
120
121   %fields = ecrc::GetECRRecord ($ecr);
122
123   if (!%fields) {
124     print "ECR $ecr was not found\n";
125   } else {
126     if (@query_fields) {
127       foreach (@query_fields) {
128         if (@query_fields > 1) {
129           if (defined $fields{$_}) {
130             print "$_: $fields{$_}\n";
131           } else {
132             print "$_: \n";
133           } # if
134         } else {
135           if (defined $fields{$_}) {
136             print "$fields{$_}\n";
137           } else {
138             print "$_: \n";
139           } # if
140         } # if
141       } # foreach
142     } else {
143       while (($key, $value) = each (%fields)) {
144         print "$key: $value\n";
145       } # while
146     } # if
147   } # if
148 } else {
149   print "Enter ECR:";
150
151   while (my $command = ) {
152     chomp $command;
153     last if $command =~ m/exit|quit/i;
154
155     $ecr = $command;
156
157     if ($ecr eq "\*") {
158       my @ecrs = ecrc::GetECRRecord $ecr;
159
160       foreach (@ecrs) {
161         print "$_\n";
162       } # foreach
163     } else {
164       %fields   = ecrc::GetECRRecord $ecr;
165
166       if (!%fields) {
167         print "ECR $ecr was not found\n";
168       } else {
169         while (($key, $value) = each (%fields)) {
170           print "$key: $value\n";
171         } # while
172       } # if
173     } # if
174
175       print "Enter ECR:";
176   } # while
177 } # if

Last modified: October 17 2016 @ 8:12 pm
Copyright © 2021, ClearSCM Inc. - All rights reserved