line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# @(#)JESFTP.pm 1.1 03/07/09 |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package MVS::JESFTP; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=pod |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
MVS::JESFTP - Perl extension for submitting JCL to MVS systems through |
10
|
|
|
|
|
|
|
FTP. |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SYNOPSIS |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
use MVS::JESFTP; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
$jes = MVS::JESFTP->open($host, $logonid, $password) or die; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
$jes->submit($job); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
$aref = $jes->wait_for_results($jobname, $timeout); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
$jes->get_results($aref); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
$jes->delete_results($aref); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
$jes->quit; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 DESCRIPTION |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
IBM mainframe MVS systems accept job input through the Job Entry |
31
|
|
|
|
|
|
|
Subsystem (JES). This input is in the form of 80-byte I |
32
|
|
|
|
|
|
|
that correspond to the punch cards of ancient times. The new releases of |
33
|
|
|
|
|
|
|
MVS can accept this input via FTP to the MVS I |
34
|
|
|
|
|
|
|
(equivalent to the physical card readers of older systems). |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
This module uses the Net::FTP module under the hood to handle the FTP |
37
|
|
|
|
|
|
|
chores. |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=cut |
40
|
|
|
|
|
|
|
|
41
|
1
|
|
|
1
|
|
625
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
36
|
|
42
|
1
|
|
|
1
|
|
5
|
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
76
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
require Exporter; |
45
|
1
|
|
|
1
|
|
1153
|
use Net::FTP; |
|
1
|
|
|
|
|
56147
|
|
|
1
|
|
|
|
|
613
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
@ISA = qw(Exporter Net::FTP); |
48
|
|
|
|
|
|
|
@EXPORT = qw(); |
49
|
|
|
|
|
|
|
$VERSION = '1.1'; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=pod |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 METHODS |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head2 $jes = MVS::JESFTP->open($host, $logonid, $password); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
This method creates a connection to the MVS system JES. If the |
58
|
|
|
|
|
|
|
connection is made, C returns a reference C<$jes> to the JES |
59
|
|
|
|
|
|
|
connection; otherwise C returns C. |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
C takes three arguments: |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=over 4 |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=item C<$host> |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
The IP address or DNS name of the MVS system. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=item C<$logonid> |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
A valid FTP logon ID for the host. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=item C<$password> |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
A valid FTP password for the host. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=back |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=cut |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub open { #------------------------------------------------------------ |
82
|
1
|
|
|
1
|
1
|
75
|
my($pkg, $host, $logonid, $password) = @_; |
83
|
|
|
|
|
|
|
|
84
|
1
|
50
|
|
|
|
11
|
my $self = Net::FTP->new($host) or return undef; |
85
|
|
|
|
|
|
|
|
86
|
0
|
0
|
|
|
|
|
$self->login($logonid, $password) or return undef; |
87
|
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
bless $self, $pkg; |
89
|
|
|
|
|
|
|
|
90
|
0
|
|
|
|
|
|
return $self; |
91
|
|
|
|
|
|
|
} #--------------------------------------------------------------------- |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=pod |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head2 $jes->submit($job); |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
This method submits the jobstream contained in the file C<$job>. If the |
98
|
|
|
|
|
|
|
submission is successful, C returns true; otherwise C |
99
|
|
|
|
|
|
|
returns C. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=cut |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub submit { #---------------------------------------------------------- |
104
|
0
|
|
|
0
|
1
|
|
my($self, $job) = @_; |
105
|
|
|
|
|
|
|
|
106
|
0
|
0
|
|
|
|
|
$self->quot('SITE', 'FILETYPE=JES JESLRECL=80') or return undef; |
107
|
|
|
|
|
|
|
|
108
|
0
|
|
|
|
|
|
return $self->put($job); |
109
|
|
|
|
|
|
|
} #--------------------------------------------------------------------- |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=pod |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head2 $aref = $jes->wait_for_results($jobname, $timeout); |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
This method waits for the output of the submitted job to arrive in the |
116
|
|
|
|
|
|
|
JES I. C returns an array reference |
117
|
|
|
|
|
|
|
C<$aref> to the a list of output files for the job suitable for input to |
118
|
|
|
|
|
|
|
C, or C if NO results could be obtained. (1) |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
C takes two arguments: |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=over 4 |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=item C<$jobname> |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
The name of the job you presumedly submitted with the C method. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=item C<$timeout> |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
How many seconds to wait for the job output to arrive; defaults to 60. |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=back |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=cut |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
sub wait_for_results { #------------------------------------------------ |
137
|
0
|
|
|
0
|
1
|
|
my($self, $JOB, $TIMEOUT) = @_; |
138
|
|
|
|
|
|
|
|
139
|
0
|
|
|
|
|
|
$JOB =~ s/\..+$//; |
140
|
0
|
|
0
|
|
|
|
$TIMEOUT ||= 60; |
141
|
|
|
|
|
|
|
|
142
|
0
|
|
|
|
|
|
my @results = (); |
143
|
0
|
|
|
|
|
|
my $i = 0; |
144
|
0
|
|
|
|
|
|
while (++$i <= $TIMEOUT) { |
145
|
|
|
|
|
|
|
# print "$i: waiting for $JOB...\n"; |
146
|
0
|
0
|
|
|
|
|
last if (@results = grep /^$JOB\s+JOB\d+\s+OUTPUT/, $self->dir); |
147
|
0
|
|
|
|
|
|
sleep(1); |
148
|
|
|
|
|
|
|
} |
149
|
0
|
0
|
|
|
|
|
return (@results) ? \@results : undef; |
150
|
|
|
|
|
|
|
} #--------------------------------------------------------------------- |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=pod |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head2 $result = $jes->get_results($aref); |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
This method retrieves the output of the submitted job from the JES |
157
|
|
|
|
|
|
|
I. C returns C if successful; |
158
|
|
|
|
|
|
|
otherwise it returns a reference to an array of names of the files |
159
|
|
|
|
|
|
|
it could NOT retrieve. (1) |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
C takes one argument: |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=over 4 |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=item C<$aref> |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
An array reference to the a list of output files from the job, such as |
168
|
|
|
|
|
|
|
C generates. C will retreive (via FTP) |
169
|
|
|
|
|
|
|
each output file in turn and store them in the current subdirectory; |
170
|
|
|
|
|
|
|
file names will be preserved. |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=back |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=cut |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
sub get_results { #----------------------------------------------------- |
177
|
0
|
|
|
0
|
1
|
|
my ($self, $ref) = @_; |
178
|
|
|
|
|
|
|
|
179
|
0
|
|
|
|
|
|
my @fails = (); |
180
|
0
|
|
|
|
|
|
foreach my $line (@$ref) { |
181
|
0
|
|
|
|
|
|
my $JOB = (split(/\s+/, $line))[1] . '.x'; |
182
|
0
|
0
|
|
|
|
|
$self->get($JOB) or push @fails, $JOB; |
183
|
|
|
|
|
|
|
} |
184
|
|
|
|
|
|
|
|
185
|
0
|
0
|
|
|
|
|
return (@fails) ? \@fails : undef; |
186
|
|
|
|
|
|
|
} #--------------------------------------------------------------------- |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=pod |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=head2 $result = $jes->delete_results($aref); |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
This method deletes the output of the submitted job from the JES |
193
|
|
|
|
|
|
|
I. C returns C if successful; |
194
|
|
|
|
|
|
|
otherwise it returns a reference to an array of names of the jobs |
195
|
|
|
|
|
|
|
it could not delete. |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
C takes one argument: |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=over 4 |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=item C<$aref> |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
An array reference to the a list of output files from the job, such as |
204
|
|
|
|
|
|
|
C generates. C will delete each job |
205
|
|
|
|
|
|
|
in turn. |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=back |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=cut |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
sub delete_results { #----------------------------------------------------- |
212
|
0
|
|
|
0
|
1
|
|
my ($self, $ref) = @_; |
213
|
|
|
|
|
|
|
|
214
|
0
|
|
|
|
|
|
my @fails = (); |
215
|
0
|
|
|
|
|
|
foreach my $line (@$ref) { |
216
|
0
|
|
|
|
|
|
my $JOB = (split(/\s+/, $line))[1]; |
217
|
0
|
0
|
|
|
|
|
$self->delete($JOB) or push @fails, $JOB; |
218
|
|
|
|
|
|
|
} |
219
|
|
|
|
|
|
|
|
220
|
0
|
0
|
|
|
|
|
return (@fails) ? \@fails : undef; |
221
|
|
|
|
|
|
|
} #--------------------------------------------------------------------- |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=pod |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
=head2 $jes->quit; |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
This method closes the connection to JES. It is just the Net::FTP |
228
|
|
|
|
|
|
|
C method. |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
=cut |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=pod |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
(1) To use this method, your JCL I card must specify a I |
235
|
|
|
|
|
|
|
that directs its output to the JES I. If you don't |
236
|
|
|
|
|
|
|
understand what this means, B, or you will hang |
237
|
|
|
|
|
|
|
your calling program. |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
=head1 PREREQUISITES |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
You have to have Net::FTP installed. |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
=head1 INSTALLATION |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
tar xzf MVS-JESFTP-1.00.tar.gz |
246
|
|
|
|
|
|
|
perl Makefile.PL |
247
|
|
|
|
|
|
|
make |
248
|
|
|
|
|
|
|
# |
249
|
|
|
|
|
|
|
# Edit TEST.SEQ to contain your site-specific logonid, |
250
|
|
|
|
|
|
|
# password, account, & node in the appropriate places. |
251
|
|
|
|
|
|
|
# |
252
|
|
|
|
|
|
|
make test |
253
|
|
|
|
|
|
|
make install |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
For Win32 systems, after unarchiving the the package, copy JESFTP.pm to |
256
|
|
|
|
|
|
|
C:\Perl\site\lib\MVS (modifying this path for your installation of |
257
|
|
|
|
|
|
|
Perl). |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
=head1 AUTHOR |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
Mike Owens |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
mike.owens@state.nm.us |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
Copyright (c) 2000 Mike Owens. All rights reserved. This program is free |
266
|
|
|
|
|
|
|
software; you can redistribute it and/or modify it under the same terms |
267
|
|
|
|
|
|
|
as Perl itself. |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, but |
270
|
|
|
|
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of |
271
|
|
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See either the GNU |
272
|
|
|
|
|
|
|
General Public License or the Artistic License for more details. |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
=head1 SEE ALSO |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
C |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
C |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
=cut |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
1; |