Skip to main content

z/OS Mainframe ftplib subclass

Project description

A FTP subclass which adds some Mainframe z/OS features like job submission, execution of sql/DB2 queries, …

Usage

import zosftplib
Myzftp = zosftplib.Zftp(mvshost, mvsuser, passwd,
                        timeout=500.0, sbdataconn='(ibm-1147,iso8859-1)')

Features

submitting sql/DB2 queries and retrieving their outputs

with open('/tmp/systables.csv', 'w') as outfile:
    for line in Myzftp.exec_sql("SELECT * FROM SYSIBM.SYSTABLES WITH UR"):
        outfile.write(';'.join(line.split()) + '\n')

submitting batch jobs, pending their outputs

# easy job for zos:
job = Myzftp.submit_wait_job('//IBMUSERX JOB MSGLEVEL(1,1)\n'
                             '//STEP001 EXEC PGM=IEFBR14',
                              purge=True)
print "rc:", job["rc"], "Jes status:", job["status"]
for line in job["output"]:
    print line

This produces the following output:

rc: RC=0000 Jes status: OUTPUT (job purged)
1                         J E S 2  J O B  L O G  --  S Y S T E M  S Y S 1  --  N O D E  N 1
0
 17.49.35 JOB03914 ---- WEDNESDAY, 27 NOV 2013 ----
 17.49.35 JOB03914  IRR010I  USERID IBMUSER  IS ASSIGNED TO THIS JOB.
 17.49.35 JOB03914  ICH70001I IBMUSER  LAST ACCESS AT 17:47:56 ON WEDNESDAY, NOVEMBER 27, 2013
 17.49.35 JOB03914  $HASP373 IBMUSERX STARTED - INIT 1    - CLASS A - SYS SYS1
 17.49.35 JOB03914  IEF403I IBMUSERX - STARTED - TIME=17.49.35
 17.49.35 JOB03914  IEF404I IBMUSERX - ENDED - TIME=17.49.35
 17.49.35 JOB03914  $HASP395 IBMUSERX ENDED
0------ JES2 JOB STATISTICS ------
-  27 NOV 2013 JOB EXECUTION DATE
-            2 CARDS READ
-           24 SYSOUT PRINT RECORDS
-            0 SYSOUT PUNCH RECORDS
-            1 SYSOUT SPOOL KBYTES
-         0.00 MINUTES EXECUTION TIME
  END OF JES SPOOL FILE
        1 //IBMUSERX JOB MSGLEVEL(1,1)                                            JOB03914
        2 //STEP001 EXEC PGM=IEFBR14
  END OF JES SPOOL FILE
 ICH70001I IBMUSER  LAST ACCESS AT 17:47:56 ON WEDNESDAY, NOVEMBER 27, 2013
 IEF142I IBMUSERX STEP001 - STEP WAS EXECUTED - COND CODE 0000
 IEF373I STEP/STEP001 /START 2013331.1749
 IEF374I STEP/STEP001 /STOP  2013331.1749 CPU    0MIN 00.01SEC SRB    0MIN 00.00SEC VIRT     4K SYS   232K EXT       0K SYS   10780K
 IEF375I  JOB/IBMUSERX/START 2013331.1749
 IEF376I  JOB/IBMUSERX/STOP  2013331.1749 CPU    0MIN 00.01SEC SRB    0MIN 00.00SEC

z/OS Catalog and JES spool informations

for x in Myzftp.list_catalog('SYS1.*'):
    print x["Dsname"], x["Dsorg"], x["Used"], "tracks"

# print all "ACTIVE" jobs:
for job in Myzftp.list_jes_spool('', '', 'ACTIVE'):
    print job

This produces the following output:

JOBNAME  JOBID    OWNER    STATUS CLASS
BPXAS    STC04218 START2   ACTIVE STC
PORTMAP  STC04182 START2   ACTIVE STC
BPXAS    STC04179 START2   ACTIVE STC
NFSC     STC04171 START2   ACTIVE STC
CICSA    STC04170 START2   ACTIVE STC
TCPIP    STC04162 TCPIP    ACTIVE STC
TN3270   STC04163 START2   ACTIVE STC
SDSF     STC04160 START2   ACTIVE STC      1 spool files
TSO      STC04158 START1   ACTIVE STC      1 spool files
INIT     STC04157 START2   ACTIVE STC
TCPIP    STC04162 TCPIP    ACTIVE STC
VTAM     STC04147 START1   ACTIVE STC
RACF     STC04164 START2   ACTIVE STC
...

Retrieve thousands of members

Myzftp.get_members('SYS1.PARMLIB', '/tmp/parmlib/')

Myzftp.get_members('SYS1.LINKLIB', '/tmp/linklib/',
                   members='*', retr='binary', ftp_threads=10)

Get/put sequential text/binary z/OS file

Myzftp.download_binary('SYS1.MAN1', '/tmp/smf.bin')

Myzftp.upload_text('/tmp/bigdata.txt', 'IBMUSER.BIGDATA',
                   sitecmd='lrecl=1024 cyl pri=500 sec=100')

Installation

The package is available as a Pip package:

$ sudo pip install zosftplib

Or using easy_install:

$ sudo easy_install zosftplib

Changelog

2.0 - (2019-01-15) 1.0 - (2013-11-25) Initial release.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zosftplib-2.0.tar.gz (301.7 kB view details)

Uploaded Source

Built Distribution

zosftplib-2.0-py2.py3-none-any.whl (11.7 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file zosftplib-2.0.tar.gz.

File metadata

  • Download URL: zosftplib-2.0.tar.gz
  • Upload date:
  • Size: 301.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.4.3

File hashes

Hashes for zosftplib-2.0.tar.gz
Algorithm Hash digest
SHA256 e7fb84c1f8b86b09327453c74ac5b8140ab756ad2981b6e41ecfbb318cc83f21
MD5 85796473cf4af8301d84be03e6c49ac6
BLAKE2b-256 dbe55a22d801e370d1d0bcc555a692f71951d3e6829bdc47eb5d0eaf74cfde88

See more details on using hashes here.

File details

Details for the file zosftplib-2.0-py2.py3-none-any.whl.

File metadata

  • Download URL: zosftplib-2.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 11.7 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.4.3

File hashes

Hashes for zosftplib-2.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 9f5b8827ded529911f232eaedd9eebbe5bee65f55372a6d4b95a3d4c20bda1f5
MD5 91d8f661f20a14e759870bb94df47368
BLAKE2b-256 0fa8262661f3fc5f0ea6004099153692f6d51cb7254fea022b65ab550d7492e0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page