将文本文件从 C# 上传到 IBM MVS
我正在尝试使用 C# 将文本文件(转换为 ebcdic)上传到 MVS 中的库中。为了上传文件,我使用了以下字符串: filename = @"ftp://xx.xx.xx .xx//'myFile'";没有撇号是不可能的。
现在,我使用了 @"ftp://xx.xx.xx.xx//' libary_name(myFile)'" 用于上传到库,但出现语法或参数错误。库名称:user_id.xyz.temp_lib 和 myFile:user_id.xyz.someFile。我该如何解决这个问题?
另外,有没有办法控制 C# 中文本文件的块大小? MVS 目前将上传的文件指定为 VB,但我希望将其指定为 FB(当然指定了长度)。
谢谢
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).
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
两个想法...
您的第一个示例暗示了对 MVS 文件名的基本误解。
与 Unix、DOS 或 MS Windows 不同,没有文件夹或“路径”之类的东西。整个 MVS 文件在系统目录中通过其唯一的数据集名称进行定义,该名称不能超过 44 个字符。文件的组织结构可能有所不同,可能有也可能没有内部目录或索引。它可以是简单的平面文件、PDS、VSAM、GDG 或数据库等。您必须了解正在使用的文件类型才能正确使用它。
在这种情况下,您将其称为“库”,并进一步指出该库有一个成员名称,该名称强烈暗示该文件被组织为 PDS 数据集。作为 PDS,有一个内部目录,并且可以有多个成员,但单个成员名称不得超过 8 个字节。成员名称计入文件名的 44 字节名称空间限制。正如 Erf 所指出的,PDS 成员名称仅限于字母、数字和一些国家字符。成员内的数据是按顺序访问的。
在第一个示例中,您指定的成员名称是: user_id.xyz.someFile
该名称显然无效,因为它超出了 8 字节限制。如果您缩短了名称,您的示例可能会起作用。事实上,在您更正的示例中,您通过创建名为“someFile”的 PDS 成员解决了非法成员名称问题,并且这是完全有效的。
第二个想法...
您说“如果在此命令上使用完整的 MVS 数据集路径,您将收到错误”。
该声明听起来不正确,表明您可能没有考虑到 FTP 会话自动将用户 ID 附加到您的文件名这一事实。虽然允许 FTP 默认您的文件名工作正常,但在大多数情况下您应该明确限定整个 MVS 文件名。
如果没有撇号,FTP 默认情况下会将您的用户 ID 附加到 MVS 文件名中。以下名称是等效的...
使用撇号,FTP 希望您显式命名完全限定的 MVS 文件名。 它不会为您附加用户 ID。
这个示例显示了差异:
您提到如果没有撇号,FTP 将无法工作。这让我很惊讶。您是否尝试过使用 C# 转义双引号 (\") 字符?我认为这也可以。
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...
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:
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.
修好了!
而不是 @"ftp://xx.xx.xx.xx//'libary_name( myFile)'" 其中库名称:user_id.xyz.temp_lib 和 myFile: user_id.xyz.someFile,您必须使用
@"ftp://xx.xx.xx.xx//'libary_name(someFile) '" 如果您在此命令上使用完整的 MVS 数据集路径,您将收到错误消息。
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.
对于 MVS ftp 服务器,您不使用 MVS 样式数据集名称。数据集名称中的每个节点都被视为一个目录。例如,如果您从“/”开始,您可以:
chdir user_id
chdir xyz
chdir 临时库
ls
将为您提供库 user_id.xyz.temp_lib 中所有成员的列表。
要上传,请尝试@“ftp:/xx.xx.xx.xx/user_id/xyz/temp_lib/myFile”。
要获取 FB 中的文件,可以使用 DCbdsn 命令:
214-DCbdsn=data_set 指定 FTP 应分配任何新数据集
214-与该数据集具有相同的属性。数据集是
214-引号中的完全限定数据集名称
214-或附加到当前目录名称前缀。
214-Blocksize、lrecl、recfm 和 retpd 参数将被覆盖
214-模型数据集特征(如果指定)。
您还可以独立使用 Blocksize、lrecl 或 recfm 选项。
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.