The format changes while ftping file from remote (unix) server to windows

Discussion of Co:Z sftp, a port of OpenSSH sftp for z/OS
Post Reply
Krishnaboya
Posts: 3
Joined: Wed Nov 30, 2016 3:02 pm

The format changes while ftping file from remote (unix) server to windows

Post by Krishnaboya »

Hi, Format of the content in the file changes when I sftp from remote server(unix) to windows.

The data in windows when I open the file in notepad changes as below, removes carriage returns. I tried linerule=crlf, crnl and without linerule option. No luck. This happens only when I open the file in notepad. If I open the file in wordpad or notepad++ the file format looks ok.

RICEW:AP_INT_001PROCESSNAME:WI_AP_VCHR_IPROCESSINSTANCE:2660730STATUS:Completed

The data is supposed to be as follows in the file (The file is logically divided into lines.).

RICEW:AP_INT_001
PROCESSNAME:WI_AP_VCHR_I
PROCESSINSTANCE:2660730
STATUS:Completed


my code is...

cozsftp $ssh_opts -b- $remoteuser@$server << EOB < $out04
lzopts mode=text,linerule=crnl
EOB

Any assistance is greatly appreciated.

Thanks!
Krishna
dovetail
Site Admin
Posts: 2022
Joined: Thu Jul 29, 2004 12:12 pm

Re: The format changes while ftping file from remote (unix) server to windows

Post by dovetail »

Windows likes CR+LF, so I would use linerule=crlf, not crnl

Please post the output from the job.
For example:

Code: Select all

Connecting to 127.0.0.1...
MYUSER@127.0.0.1's password: 
Connected to 127.0.0.1.
Connection established, local_addr=127.0.0.1 local_port=1093 remote_addr=127.0.0.1 remote_port=22
cozsftp> lzopts mode=text,linerule=crlf
 linerule=crlf   mode=text      
cozsftp> put //MYUSER.TEST.DSN /tmp/test.tmp
Uploading //MYUSER.TEST.DSN to /tmp/test.tmp
ZosSettings[I]: Transfer options: clientcp=IBM-1047,linerule=crlf,mode=text,servercp=IBM-1047,trim
ZosDataset[I]: Opening dataset MYUSER.TEST.DSN for read with options: shr
ZosDataset[I]: Closing dataset //MYUSER.TEST.DSN - 1 records read, 19 bytes sent
Krishnaboya
Posts: 3
Joined: Wed Nov 30, 2016 3:02 pm

Re: The format changes while ftping file from remote (unix) server to windows

Post by Krishnaboya »

Thank you for the response. I did try lzopts mode=text,linerule=crlf. See output below. Thank you!

Here is my script

echo "--- constructing commands to put local files to lan ---"
echo "pwd" > $out04
echo "ls -1" >> $out04
echo "cd $landir" >> $out04
echo "ls -1" >> $out04
echo "cd $STAR_INFC_TY" >> $out04
echo "ascii" >> $out04

cat $out02 | awk '
{
print "put " $1
}' >> $out04

pwd
cozsftp $ssh_opts -b- $remoteuser@$server << EOB < $out04
lzopts mode=text,linerule=crlf
EOB
#

Here is a job output

cozsftp> ascii
mode=text
cozsftp> put AP_INT_001_I_395_20160816160008_CAR_ack.txt
Uploading AP_INT_001_I_395_20160816160008_CAR_ack.txt to /lan-dir/AP_INT_001/AP_INT_001_I_395_20160816160008_CAR_ack.txt
cozsftp> put AP_INT_001_I_395_20160816160008_CAR_log.txt
Uploading AP_INT_001_I_395_20160816160008_CAR_log.txt to /lan-dir/AP_INT_001/AP_INT_001_I_395_20160816160008_CAR_log.txt
cozsftp> put AP_INT_001_I_395_20160819110003_TAS_ack.txt
Uploading AP_INT_001_I_395_20160819110003_TAS_ack.txt to /lan-dir/AP_INT_001/AP_INT_001_I_395_20160819110003_TAS_ack.txt
cozsftp> put AP_INT_001_I_395_20160819110003_TAS_log.txt
Uploading AP_INT_001_I_395_20160819110003_TAS_log.txt to /lan-dir/AP_INT_001/AP_INT_001_I_395_20160819110003_TAS_log.txt
sftp rc = 0
--- local files transferred successfully to lan ---
Last edited by Krishnaboya on Fri Dec 02, 2016 10:49 am, edited 1 time in total.
dovetail
Site Admin
Posts: 2022
Joined: Thu Jul 29, 2004 12:12 pm

Re: The format changes while ftping file from remote (unix) server to windows

Post by dovetail »

Your log shows that you are not using linerule=crlf.
Something seems to be wrong with your script, in particular line:

cozsftp $ssh_opts -b- $remoteuser@$server << EOB < $out04

Are your input commands coming from the file pointed to by $out4? I don't thing that you can use "<<" (here doc) input redirection on the same z/OS Unix shell command as "< file" input redirection.
Krishnaboya
Posts: 3
Joined: Wed Nov 30, 2016 3:02 pm

Re: The format changes while ftping file from remote (unix) server to windows

Post by Krishnaboya »

I have updated my post, please look into it.

It successfully transfers the file, but the content in the file changes as
RICEW:AP_INT_001PROCESSNAME:WI_AP_VCHR_IPROCESSINSTANCE:1629179STATUS:Completed.
dovetail
Site Admin
Posts: 2022
Joined: Thu Jul 29, 2004 12:12 pm

Re: The format changes while ftping file from remote (unix) server to windows

Post by dovetail »

I'm not going to rewrite your script, but what I'm saying is that this line is wrong:

cozsftp $ssh_opts -b- $remoteuser@$server << EOB < $out04

You should add the lzopts subcommand to the beginning of your $out04 file and eliminate the <<EOB here document. You can't do both.
Post Reply