uploading text file from C# to IBM MVS
I'm trying to upload a text file (converted to ebcdic) into a library in MVS using C#. For uploading a file, I used the following string: filename = @"ftp://xx.xx.xx.xx//'myFile'"; It is not possible without the apostrophes.
Now, I used @"ftp://xx.xx.xx.xx//'libary_name(myFile)'" for upload into a library but I get incorrect syntax or parameters error. Library name: user_id.xyz.temp_lib and myFile: user_id.xyz.someFile. How do I go about fixing this?Also, is there a way to control the block size of the text file in c#? MVS currently states the uploaded file as VB but I want it as FB (length specified of course).
T开发者_高级运维hanks
Two thoughts...
Your first example suggests a basic misunderstanding of MVS file names.
Unlike Unix, DOS or MS Windows there is no such thing as a folder or "path". The entire MVS file is defined in the system catalog by its unique dataset name which can not exceed 44 characters. The file can vary in organizational structure which may or may not have an internal directory or index. It can be a simple flat file, or a PDS, or VSAM, or GDG, or database etc. You have to understand what type of file you are working with to use it correctly.
In this situation, you called it a "library" and you further indicated this library has a member name which strongly hints that the file is organized as a PDS dataset. As a PDS, there is an internal directory and you can have multiple members, but no single member name may exceed 8 bytes. The member name counts toward the 44 byte name space limitation of the file name. As Erf indicated, the PDS member name is limited to letters, numbers and a few national characters. The data within the member is accessed sequentially.
In your first example you indicated the member name is: user_id.xyz.someFile
That name is obviously invalid as it exceeds the 8 byte limit. If you had shortend the name your example may have worked. Indeed, it appears in your corrected example that you fixed the illegal member name issue by creating a PDS member called "someFile" and that is pefectly valid.
2nd thought...
You said "If you use the full MVS data set path on this command, you will get an error."
That statement sounds incorrect and indicates you may not have allowed for the fact that the FTP session is appending the user id to your file name automatically. While allowing FTP to default your file name works fine, in most cases you should explicitly qualify the entire MVS file name.
Without the apostrophes, FTP should append your user id to the MVS file name by default. The following names are equivalent...
@"ftp://xx.xx.xx.xx//libary_name(aMember)"
@"ftp://xx.xx.xx.xx//'user_id.libary_name(aMember)'"
With the apostrophes, FTP expects you to explicitly name the fully-qualified MVS file name. It will not append the user id for you.
This example shows the difference:
@"ftp://xx.xx.xx.xx//libary_name(aMember)" <- user_id.libary_name(aMember)
@"ftp://xx.xx.xx.xx//'xyz.libary_name(aMember)'" <- xyz.libary_name(aMember)
You mentioned that FTP will not work without apostrophes. That surprises me. Have you tried using the C# escape double-quote (\") character instead? I think that would work as well.
Fixed it!
Instead of @"ftp://xx.xx.xx.xx//'libary_name(myFile)'" where Library name: user_id.xyz.temp_lib and myFile: user_id.xyz.someFile, you have to use @"ftp://xx.xx.xx.xx//'libary_name(someFile)'" If you use the full MVS data set path on this command, you will get an error.
For the MVS ftp server, you don't use the MVS style dataset name. Each node in the dataset name is treated as a directory. For example, if you started at "/", you could:
chdir user_id chdir xyz chdir temp_lib ls
would get you a listing of all the members in the library user_id.xyz.temp_lib.
To upload, try @"ftp:/xx.xx.xx.xx/user_id/xyz/temp_lib/myFile".
To get the file in FB, you can use the DCbdsn command:
214-DCbdsn=data_set Specifies that FTP should allocate any new data sets 214- with the same attributes as this data set. Data_set is 214- either a fully qualified data set name in quotes 214- or appended to the present directory name prefix. 214- Blocksize, lrecl, recfm and retpd parameters will override 214- the model data set characteristics if they are specified.
You can also use the Blocksize, lrecl or recfm options independantly.
精彩评论