Parent Directory
|
Revision Log
Revision 1.3 - (view) (download) (as text)
1 : | parrello | 1.1 | #!/usr/bin/perl -w |
2 : | |||
3 : | =head1 Single Table Load | ||
4 : | |||
5 : | This script loads one or more Sprout table from an existing DTX file. | ||
6 : | |||
7 : | parrello | 1.2 | It takes as positional parameters the table names. The command-line |
8 : | options are as follows. | ||
9 : | |||
10 : | =over 4 | ||
11 : | |||
12 : | =item trace | ||
13 : | |||
14 : | Desired tracing level. The default is 3. | ||
15 : | |||
16 : | =item user | ||
17 : | |||
18 : | Suffix to use for trace, output, and error files created. | ||
19 : | |||
20 : | =item background | ||
21 : | |||
22 : | Redirect the standard and error output to files in the FIG temporary directory. | ||
23 : | |||
24 : | =item sql | ||
25 : | |||
26 : | Trace SQL statements. | ||
27 : | |||
28 : | =item phone | ||
29 : | |||
30 : | Phone number to message when the load finishes. | ||
31 : | |||
32 : | =back | ||
33 : | parrello | 1.1 | |
34 : | =cut | ||
35 : | |||
36 : | use strict; | ||
37 : | use Tracer; | ||
38 : | use Cwd; | ||
39 : | use Sprout; | ||
40 : | use SFXlate; | ||
41 : | use File::Copy; | ||
42 : | use File::Path; | ||
43 : | |||
44 : | # Get the command-line options. | ||
45 : | my ($options, @parameters) = StandardSetup(['ERDB', 'Sprout', 'DBKernel'], | ||
46 : | { | ||
47 : | parrello | 1.2 | phone => ["", "phone number (international format) to call when load finishes"], |
48 : | parrello | 1.1 | }, |
49 : | '<table1> <table2> ...', | ||
50 : | @ARGV); | ||
51 : | parrello | 1.2 | # Set a variable to contain return type information. |
52 : | my $rtype; | ||
53 : | # Insure we catch errors. | ||
54 : | eval { | ||
55 : | # Get a Sprout object. | ||
56 : | my $sprout = SFXlate->new_sprout_only(); | ||
57 : | # Attempt the load. Note that we have the truncate flag on to force the table | ||
58 : | # to be rebuilt. | ||
59 : | $sprout->LoadUpdate(1, \@parameters); | ||
60 : | }; | ||
61 : | if ($@) { | ||
62 : | Trace("Load failed with error: $@") if T(0); | ||
63 : | $rtype = "error"; | ||
64 : | } else { | ||
65 : | Trace("Load complete.") if T(2); | ||
66 : | $rtype = "no error"; | ||
67 : | } | ||
68 : | if ($options->{phone}) { | ||
69 : | my $msgID = Tracer::SendSMS($options->{phone}, "Sprout table load terminated with $rtype."); | ||
70 : | if ($msgID) { | ||
71 : | Trace("Phone message sent with ID $msgID.") if T(2); | ||
72 : | } else { | ||
73 : | Trace("Phone message not sent.") if T(2); | ||
74 : | } | ||
75 : | } | ||
76 : | parrello | 1.1 | |
77 : | 1; |
MCS Webmaster | ViewVC Help |
Powered by ViewVC 1.0.3 |