Use MVS Dsname conventions. Mainframe name convention while downloading ftp using python

298 views Asked by At

I used the following codes but the error message is as follows. I dont know how to fix it. THis is the error. '501 Invalid data set name "Qxxx.Pxxx.xxxxxx.xxxx.xxx.xxxxx". Use MVS Dsname conventions. Can you please help me?

ftp_host = "host"
ftp_user = "username"
ftp_password = "passw"
filename = 'Qxxx.Pxxx.xxxxxx.xxxx.xxx.xxxxxx'


try:
    ftp_server = FTP(ftp_host, ftp_user, ftp_password)
    print("good")
    ftp_server.set_pasv(False)
    with open(filename,'wb') as file:
        ftp_server.retrbinary(f'RETR {filename}',file.write)

except Exception as e:
    print(e)

3

There are 3 answers

1
Rui Vieira On

Review if the filename meets requirements bellow.

The data set name must:

  • Be no more than 44 characters total
  • Each qualifier must be no more than 8 characters total
  • Each qualifier must start with a letter or with a dollar sign ($), an at sign (@), or a number sign (#).
  • The 2nd–8th characters of each qualifier must be either a letter, a number, or a dollar sign ($), an at sign (@), a number sign (#), a hyphen (-), or a brace ( }).

From: https://www.ibm.com/docs/en/zos/2.1.0?topic=5rc-501-invalid-data-set-name-use-mvs-dsname-conventions

0
cschneid On

Depending on any number of factors your userid may be added as a prefix to your dataset name on the server side. Try enclosing your file name in apostrophes, which is the MVS convention for "don't prefix my dataset name with my userid."

Maybe...

filename = "'QXXY.SRXYL.CXTGID20.FLXDT4.RUNA.M0018V00'"

...will work.

1
Pasamonte On

An existing dataset doesn’t imply that the communications server is able to FTP it. The last qualifier is longer than 8 characters: M0018V000

Dataset naming convention for FTP is quite restrictive: https://www.ibm.com/docs/en/zos/2.1.0?topic=ftp-mvs-naming-conventions

Even for the last z/OS version: https://www.ibm.com/docs/en/zos/3.1.0?topic=ftp-mvs-naming-conventions