download ANSI file using SFTP from OpenVms to windows system. Extra nul characters added in the file

497 Views Asked by At

I have some files on an OpenVms system. .xml, .cfg, and some binary files. The encoding type of those files is ANSI. When I use FTP mode binary to download, all works fine.

But if I use SFTP (doesn't matter which client I use) to download, extra NUL characters are added in the file.

Does anyone have the same problem?

2

There are 2 best solutions below

1
Mark Diaz On

Agree this may not be the best forum for the question. But, in general, if you have what are essentially text files (xml) explicitly setting the FTP transfer mode to text should help. Some FTP servers/clients guess if the file is text or binary based on the file type (.xml).

0
Hein On

user8436611, there is no such thing as an 'ANSI' file in OpenVMS terminology. Perhaps you mean a file containing simple 7-bit ASCII characters only ??

On OpenVMS simple 'sequential' files holding simple text, can still have multiple record 'formats'.

The native OpenVMS format is called VARIABLE LENGTH. Use DIRECTORY /FULL to report the file type or the DCL command $ WRITE SYS$OUTPUT F$FILE_ATTRIBUTES(filespec,"RFM") For a variable length file, each record (line) is prefix with a (16-bit) word aligned, (16 bit) binary length indicator word. For a 'short' line (< 256 bytes) that will show a binary zero byte. And any odd-length record will appear to be followed by a null-byte to align the next record length word. (word = int-2)

If such file is transferred binary, most tools will chunk it up in 512 bytes blocks, with that control word, and optional align byte included, looking like binary zeros on the other side.

Therefor, as Mark Diaz indicated you need to tell your tool to transfer in 'ASCII' or 'TEXT' mode.

OpenVMS also supports 'normal' files where each record (line) is followed by a terminator which can be a Linefeed (Unix), Carriage-return, or CR-LF (windows).

If your OpenVMS file is indeed the normal-for-OpenVMS variable length file as I suspect, then you could consider 'converting' it to 'Stream_LF' using an 'FDL' file or string. Example DCL command: $ CONVERT/FDL="RECORD; FORMAT STREAM_LF" old.dat new.dat

Good luck, Hein