Sure this is the doc for the python FTP module: 
https://docs.python.org/3/library/ftplib.html

That contains some sample syntax for the python module, this is a quick generic 
script I wrote up. You will need to make sure python, ftplib, and io libraries 
are downloaded on the linux server. You can basically copy and paste this into 
a script.py on the server and "chmod 775 script.py" to give it write access. 
The you can do crontab -e to setup the cronjob for scheduled runs 
(https://crontab.guru/ is great tool to translate the cron syntax to time)

This script is written to do both but  if you see in the main() function one of 
the lines is commented out ( #upload() ) meaning it won't run the upload() 
function. You could take the comment so both upload and download happen right 
after each other but it sounded like you wanted to wait on the user to do their 
thing first. Or you could split this up into separate download.py and upload.py 
and schedule them via crontab appropriately..... Or you could add in args = 
sys.argv[1:] under main() and setup flags so it only runs based on the flag in 
cronjob.... Python has got a million ways to do one thing so feel free to 
evolve this 

P.S the space indents are important so make sure the copy/paste contains those

#!/usr/bin/python3
from ftplib import  FTP
import io 

userfile = "/home/user/file1.txt"

def download():
    ftp = FTP('192.168.1.1') #
    ftp.login('username', 'password')
    dataset = []
    ftp.retrlines('RETR \'DATA.SET.NAME.HERE\'', dataset.append)

    download = ""

    for x in dataset:
        download += x + "\n"

    with open(userfile, 'w+', encoding="utf-8") as a:
        a.write(download)

def upload():
    ftp = FTP('192.168.1.1')
    ftp.login('username', 'password')
    
    with open(userfile, 'r') as b:
        fixed = b.read()
        
    b = io.BytesIO()
    b.write(fixed.encode())
    b.seek(0)
    
    ftp.storlines("STOR \'DATA.SET.NAME.HERE\'", B)

def main():
    download()
    #upload()

if __name__ == "__main__":
    main()

Thanks,
Angel Jara
Systems Programmer I
NC Farm Bureau Mutual Insurance Co. Inc.
5301 Glenwood Ave, Raleigh, NC 27612
919-782-1705 | Ext 3588


-----Original Message-----
From: IBM Mainframe Discussion List <IBM-MAIN@LISTSERV.UA.EDU> On Behalf Of 
Jake Anderson
Sent: Tuesday, August 16, 2022 12:02 PM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: Re: Automatic ftp process


WARNING: This email originated outside of North Carolina Farm Bureau. DO NOT 
CLICK links or attachments unless you recognize the sender and know the content 
is safe.

Hello Angel

Thanks for your sharing.

Do you have a sample python script for this process or you would be able to 
point me in the right direction for sample python script from some GIT ?

On Tue, Aug 16, 2022, 7:34 PM Angel Jara < 
00000444f3c91457-dmarc-requ...@listserv.ua.edu> wrote:

> As far as the Linux side goes, I use python and it's FTP module on the 
> linux server to send files from a user directory on the linux server 
> to the mainframe which is then accessible. Once you do the changes on 
> the mainframe, then you can also use python on the linux server to ftp 
> down the new/changed dataset from the mainframe and have it stored in 
> the user's repository. You could set this up as a cronjob on the linux 
> server so it occurs at specific times, hourly, daily, weekly, or 
> monthly
>
> Thanks,
> Angel
>
> -----Original Message-----
> From: IBM Mainframe Discussion List <IBM-MAIN@LISTSERV.UA.EDU> On 
> Behalf Of Carmen Vitullo
> Sent: Tuesday, August 16, 2022 9:59 AM
> To: IBM-MAIN@LISTSERV.UA.EDU
> Subject: Re: Automatic ftp process
>
>
> WARNING: This email originated outside of North Carolina Farm Bureau. 
> DO NOT CLICK links or attachments unless you recognize the sender and 
> know the content is safe.
>
> CDC IIRC supports DB's other than DB2, on the Mainframe, I worked with 
> a product from Oracle that performed about the same task, running in 
> Unix System Services, it supported Oracle and DB2 IIRC on the 
> mainframe. I forget the product since it's been about 12 years since 
> we did a POC for the product
>
> Carmen
>
>
> On 8/16/2022 8:54 AM, Jake Anderson wrote:
> > It's basically we run a non IBM Database in mainframe
> >
> > The user(management) have a list of employees code where they want 
> > to know some of their personal data of employees from mainframe Database.
> >
> > So here management or the requestor doesn't have mainframe access 
> > and we as mainframer will pick the list from repository from where 
> > they save and we fetch all the data from Mainframe database and save 
> > it back to the same repository.
> >
> > On Tue, Aug 16, 2022, 5:35 PM Carmen Vitullo <petevi...@gmail.com>
> wrote:
> >
> >> any record? any file?
> >>
> >> maybe there's some DASD replication tool for this ?  we do this for 
> >> DASD subsystems to another subsystem for DR
> >>
> >> for Data bases there's IBM's Info-sphere change data capture
> >>
> >> Carmen
> >>
> >> On 8/16/2022 8:24 AM, Jake Anderson wrote:
> >>> Hi
> >>>
> >>> We have requirement whenever someone saves a  record(non-mainframe
> >>> user)
> >> in
> >>> Linux.We automatically wants to get those record and ftp to 
> >>> mainframe and and pull all details from database then save it back 
> >>> to the same location where the user saves his Initial record.
> >>>
> >>> Has anyone tried this similar exercise and would like to share 
> >>> your experience or provide me some pointers on where I can start 
> >>> this with
> >>>
> >>> Jake
> >>>
> >>> ------------------------------------------------------------------
> >>> --
> >>> -- For IBM-MAIN subscribe / signoff / archive access instructions, 
> >>> send email to lists...@listserv.ua.edu with the message: INFO 
> >>> IBM-MAIN
> >> -------------------------------------------------------------------
> >> --
> >> - For IBM-MAIN subscribe / signoff / archive access instructions, 
> >> send email to lists...@listserv.ua.edu with the message: INFO 
> >> IBM-MAIN
> >>
> > --------------------------------------------------------------------
> > -- For IBM-MAIN subscribe / signoff / archive access instructions, 
> > send email to lists...@listserv.ua.edu with the message: INFO 
> > IBM-MAIN
>
> ----------------------------------------------------------------------
> For IBM-MAIN subscribe / signoff / archive access instructions, send 
> email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
>
> ----------------------------------------------------------------------
> For IBM-MAIN subscribe / signoff / archive access instructions, send 
> email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
>

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions, send email to 
lists...@listserv.ua.edu with the message: INFO IBM-MAIN

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to