0
1
I want to download a file from a mainframe server to a Linux machine using an SFTP command and want to preserve EOL. It seems that the actual file does not have EOL characters, whereas the SFTP process adds EOL characters while downloading it to the Linux server.
Is there any option to download the file in binary mode using an SFTP command?
I tried to download data from the mainframe server using FTP and SFTP. FTP with binary mode preserves the actual content of original file without any modification, whereas FTP with ASCII mode and SFTP commands are modifying the content of the file by adding EOL and other special characters.
I used the following SFTP command to download the file from the mainframe server:
[ABC@XXXXXX.XXX.XXX.XXX.com: /var/fedex/srs/rcd/data/Dev/serial/Src/Private/src_intl_rating/main/ABC ]$ sftp XYZ@XXX.XXX.XXX.com
* * * * * * * * * * * * * * * * * * * * * * * * * * *
* NOTE: YOU ARE CONNECTING VIA IBM'S SSH PORTED *
* TOOLS. *
* DEV2. *
* THIS IS IN TEST MODE AND MAY NOT FUNCTION *
* AS EXPECTED. *
* * * * * * * * * * * * * * * * * * * * * * * * * * *
XYZ@XXX.XXX.XXX.com's password:
Connected to XXX.XXX.XXX.com.
sftp> binary
Invalid command.
sftp> get //SYS2542.RTSB.RCD130.OUT.FEAB091
Fetching //SYS2542.RTSB.RCD130.OUT.FEAB091 to SYS2542.RTSB.RCD130.OUT.FEAB091
//SYS2542.RTSB.RCD130.OUT.FEAB091 99% 2620KB 2.0MB/s 00:00 ETA
sftp> bye
[ABC@XXXXXX.XXX.XXX.XXX.com: /var/fedex/srs/rcd/data/Dev/serial/Src/Private/src_intl_rating/main/ABC ]$ ls -ltr
total 22360
-rw-r--r-- 1 ABC rcd 2682504 Jul 26 03:49 FTP.SYS2542.RTSB.RCD130.OUT.FEAB091.ASCII
-rw-r--r-- 1 ABC rcd 2680128 Jul 26 03:50 FTP.SYS2542.RTSB.RCD130.OUT.FEAB091.BINARY
-rw-r--r-- 1 ABC rcd 2682504 Jul 26 15:21 SYS2542.RTSB.RCD130.OUT.FEAB091
[ABC@XXXXXX.XXX.XXX.XXX.com: /var/fedex/srs/rcd/data/Dev/serial/Src/Private/src_intl_rating/main/ABC ]$ mv SYS2542.RTSB.RCD130.OUT.FEAB091 SFTP.SYS2542.RTSB.RCD130.OUT.FEAB091
[ABC@XXXXXX.XXX.XXX.XXX.com: /var/fedex/srs/rcd/data/Dev/serial/Src/Private/src_intl_rating/main/ABC ]$ ls -ltr
total 22360
-rw-r--r-- 1 ABC rcd 2682504 Jul 26 03:49 FTP.SYS2542.RTSB.RCD130.OUT.FEAB091.ASCII
-rw-r--r-- 1 ABC rcd 2680128 Jul 26 03:50 FTP.SYS2542.RTSB.RCD130.OUT.FEAB091.BINARY
-rw-r--r-- 1 ABC rcd 2682504 Jul 26 15:21 SFTP.SYS2542.RTSB.RCD130.OUT.FEAB091
[ABC@XXXXXX.XXX.XXX.XXX.com: /var/fedex/srs/rcd/data/Dev/serial/Src/Private/src_intl_rating/main/ABC ]$
"does not have EOL character" - What does that even mean? Is it a binary file? – Martin Prikryl – 2019-07-26T16:08:29.873
New line character. The original file does not have that character which was generated from a mainframe process. Somehow SFTP is adding this, due to which our downstream processes are failing. – Dilip Panda – 2019-07-26T16:11:43.473
I know what EOL is. So even if your question said "does not have New line character", my question is still the same: What does that even mean? Is it a binary file? Or a text file that has a single line only (so has no new line character)? Or something else? – Martin Prikryl – 2019-07-26T16:23:08.337
I am not sure if it is a binary file or not? Since the file was generated by Mainframe process, there are no EOL character is there in the file. I wanted to get the same file with SFTP command which i got using FTP command with Binary transfer mode. My Downstream apps are working fine on the file downloaded using FTP Binary method. – Dilip Panda – 2019-07-26T16:56:40.433
Is there any way you could use
scp
instead ofsftp
?scp
always transfers files in "binary mode" (it doesn't even have an "ASCII mode").scp
works over the SFTP protocol. – Cliff Armstrong – 2019-07-27T06:30:32.247@CliffArmstrong 1) OpenSSH
– Martin Prikryl – 2019-07-27T06:37:04.950sftp
also always transfers files in "binary mode" (doesn't even have an "ASCII mode"). 2) OpenSSHscp
does not work over the SFTP protocol. – I do not mean that your suggestion to usescp
could not help – after all this looks like a bug/feature of the z/OS SFTP server – see also a answer by @Hogstrom to OP's duplicate question on SO – but your claims are not correct.Very well, I stand corrected regarding scp<>sftp. However, what you described happening is most definitely not binary mode. Regardless of whether the server of the client is causing the issue... binary mode, by definition, does not change the content of the file as part of the transfer. And the entire point of ASCII mode was to enable swapping EOL character formats across operating systems. So forgive me for thinking you were somehow ending up with an ASCII mode file transfer based on the description of your issue. – Cliff Armstrong – 2019-07-27T07:01:18.120