1 #!/usr/bin/perl |
|
2 |
|
3 =head1 NAME |
|
4 |
|
5 Record delivery |
|
6 |
|
7 =head1 SYNOPSIS |
|
8 |
|
9 record_delivery.pl |
|
10 |
|
11 =head1 DESCRIPTION |
|
12 |
|
13 This script is designed to send an email for the purpose of recording deliveries. |
|
14 |
|
15 =head1 COPYRIGHT |
|
16 |
|
17 Copyright (c) 2005-2006 Symbian Ltd. All rights reserved |
|
18 |
|
19 =cut |
|
20 |
|
21 use strict; |
|
22 |
|
23 use Getopt::Long; |
|
24 |
|
25 use FindBin; # for FindBin::Bin |
|
26 use lib $FindBin::Bin; # For Local modules |
|
27 |
|
28 use record_delivery; |
|
29 |
|
30 my %gEntries; |
|
31 |
|
32 my ($iConfig, $iTemplates, $iEntries) = ProcessCommandLine(); |
|
33 |
|
34 #Convert the entries to a hash |
|
35 foreach my $iEntry (@$iEntries) |
|
36 { |
|
37 my ($key, $value) = $iEntry =~ /(.*?)=(.*)/; |
|
38 $gEntries{$key} = $value; |
|
39 } |
|
40 my $delivery = record_delivery->new(config_file => $iConfig); |
|
41 foreach my $iTemplate (@$iTemplates) |
|
42 { |
|
43 eval { |
|
44 $delivery->send(Template => $iTemplate, %gEntries); |
|
45 }; |
|
46 if ($@) |
|
47 { |
|
48 print "ERROR: Failed to record delivery using Template $iTemplate - $@\n"; |
|
49 } else { |
|
50 print "Delivery Email Sent using Template $iTemplate\n"; |
|
51 } |
|
52 } |
|
53 |
|
54 |
|
55 |
|
56 # ProcessCommandLine |
|
57 # |
|
58 # Inputs |
|
59 # |
|
60 # Outputs |
|
61 # $ilog - logfile location |
|
62 # |
|
63 # Description |
|
64 # This function processes the commandline |
|
65 |
|
66 sub ProcessCommandLine { |
|
67 my ($iHelp, @iTemplates, $iConfig, @iEntries); |
|
68 |
|
69 GetOptions('h' => \$iHelp, 't=s' => \@iTemplates, 'c=s' => \$iConfig, 'e=s' => \@iEntries); |
|
70 |
|
71 if (($iHelp) || (scalar(@iTemplates) == 0) || (!defined $iConfig) || (scalar(@iEntries) == 0)) |
|
72 { |
|
73 &Usage(); |
|
74 } else { |
|
75 return($iConfig, \@iTemplates, \@iEntries); |
|
76 } |
|
77 } |
|
78 |
|
79 # Usage |
|
80 # |
|
81 # Output Usage Information. |
|
82 # |
|
83 |
|
84 sub Usage { |
|
85 print <<USAGE_EOF; |
|
86 |
|
87 Usage: record_delivery.pl [options] |
|
88 |
|
89 options: |
|
90 |
|
91 -h help |
|
92 -t [filename] HTML::Template file to use [Multiple Allowed] |
|
93 -c [filename] configuration file to use |
|
94 -e [Key=Value] Template Key and associated Value [Multiple Allowed] |
|
95 |
|
96 The parameters to the -e option must be provided in the form Key=Value |
|
97 e.g BuildNumber=20 |
|
98 This will replace the "<TMPL_VAR NAME=BuildNumber>" text in the |
|
99 HTML::template file with the text "20". |
|
100 Keys listed on the commandline that do not exist in the template |
|
101 will generate an ERROR. |
|
102 Keys listed in the template but not provided on the command line will not |
|
103 generate an error. |
|
104 |
|
105 Example Commandline |
|
106 record_delivery.pl -t SymbianKK.tmpl -c testemail.cfg -e BuildNumber=03803_Symbian_OS_v9.2 -e PublishLocation=\\\\builds01\\devbuilds |
|
107 |
|
108 USAGE_EOF |
|
109 exit 1; |
|
110 } |
|