[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

net::ftp puttextfile to os/390

dkmd_nielsen

6/29/2006 1:00:00 AM

I'm sure you don't get too many mainframe related questions. First the
code, then my blather.

f = Net::FTP.open("wouldntyou.liketoknow.com","anonymous")
f.chdir("'#{prj.mainframe_prefix}'")
f.site("LOCSITE BLOCKS BLKSIZE=0 LRECL=124 RECFM=FB PRIMARY=500
SECONDARY=500")
f.puttextfile("#{prj.networkfolder}\\#{prj.deptrun}_flc_cards.txt","FLC")
f.site("LOCSITE BLOCKS BLKSIZE=0 LRECL=60 RECFM=FB PRIMARY=500
SECONDARY=500")
f.puttextfile("#{prj.networkfolder}\\#{prj.deptrun}_flc_cards.txt","PRTY")
f.close


I'm attempting to ftp a network based text file to the mainframe (ascii
to ebcdic). Everything operates without error, but only the first
record of the file is transmitted. I added a code block to the
puttextfile function and a puts to display everything being sent. Yep,
just one line. Each text line does have a CRLF at the end. I tried it
without the CRLF. That was no go, too.

I tried setting TYPE A and then using just put. put sent the file
binary, anyway. But atleast the binary gobbldee gook appears to have
sent all the records.

Your thoughts are appreciated,
dvn - I've googled everything I can possibly think of.
dvn

4 Answers

Frank Swarbrick

6/29/2006 4:27:00 AM

0

dkmd_nielsen@hotmail.com wrote:
> I'm sure you don't get too many mainframe related questions. First the
> code, then my blather.
>
> f = Net::FTP.open("wouldntyou.liketoknow.com","anonymous")
> f.chdir("'#{prj.mainframe_prefix}'")
> f.site("LOCSITE BLOCKS BLKSIZE=0 LRECL=124 RECFM=FB PRIMARY=500
> SECONDARY=500")
> f.puttextfile("#{prj.networkfolder}\\#{prj.deptrun}_flc_cards.txt","FLC")
> f.site("LOCSITE BLOCKS BLKSIZE=0 LRECL=60 RECFM=FB PRIMARY=500
> SECONDARY=500")
> f.puttextfile("#{prj.networkfolder}\\#{prj.deptrun}_flc_cards.txt","PRTY")
> f.close
>
>
> I'm attempting to ftp a network based text file to the mainframe (ascii
> to ebcdic). Everything operates without error, but only the first
> record of the file is transmitted. I added a code block to the
> puttextfile function and a puts to display everything being sent. Yep,
> just one line. Each text line does have a CRLF at the end. I tried it
> without the CRLF. That was no go, too.
>
> I tried setting TYPE A and then using just put. put sent the file
> binary, anyway. But atleast the binary gobbldee gook appears to have
> sent all the records.

Dumb question, perhaps, but have you tried it from just a regular FTP
client?
Are you seeing any error messages on the mainframe side? (Not sure if
there's an error log of any type.)

Frank

dkmd_nielsen

6/29/2006 12:37:00 PM

0

This is definitely a disconnect between my mainframe backgrounds and
ascii pc/network knowledge. When I create my file with Ruby, I append
a '\r' to the end of each record [io.syswrite(flc.build+"\r")]. I do
this so the file is displayed properly by text editors. When I go to
transmit this file, I get an extra 0d at the end of the record in
recieved file. That I can see that on the mainframe side. If I create
the file one byte longer than the actual data and use WRAP, then the
records write correctly with the x0d at the end. It is my thought that
the x0a0d should be truncated off the end of the record.

I'm assuming my problem is on the mainframe side. When I trace the FTP
on the Ruby end, it appears to send the entire file as one big chunk.
So that means it is up to the mainframe to perform the proper chomp.
(Which is interesting because Net::FTP does a chomp and appends a
CRLF.)

I have done the ftp transfer from the command line, using the same site
commands to setup the recieving file. It behaves the same. I must be
missing some site command to tell ftp to lose the extra byte.

dvn

Frank Swarbrick wrote:
> dkmd_nielsen@hotmail.com wrote:
> > I'm sure you don't get too many mainframe related questions. First the
> > code, then my blather.
> >
> > f = Net::FTP.open("wouldntyou.liketoknow.com","anonymous")
> > f.chdir("'#{prj.mainframe_prefix}'")
> > f.site("LOCSITE BLOCKS BLKSIZE=0 LRECL=124 RECFM=FB PRIMARY=500
> > SECONDARY=500")
> > f.puttextfile("#{prj.networkfolder}\\#{prj.deptrun}_flc_cards.txt","FLC")
> > f.site("LOCSITE BLOCKS BLKSIZE=0 LRECL=60 RECFM=FB PRIMARY=500
> > SECONDARY=500")
> > f.puttextfile("#{prj.networkfolder}\\#{prj.deptrun}_flc_cards.txt","PRTY")
> > f.close
> >
> >
> > I'm attempting to ftp a network based text file to the mainframe (ascii
> > to ebcdic). Everything operates without error, but only the first
> > record of the file is transmitted. I added a code block to the
> > puttextfile function and a puts to display everything being sent. Yep,
> > just one line. Each text line does have a CRLF at the end. I tried it
> > without the CRLF. That was no go, too.
> >
> > I tried setting TYPE A and then using just put. put sent the file
> > binary, anyway. But atleast the binary gobbldee gook appears to have
> > sent all the records.
>
> Dumb question, perhaps, but have you tried it from just a regular FTP
> client?
> Are you seeing any error messages on the mainframe side? (Not sure if
> there's an error log of any type.)
>
> Frank

dkmd_nielsen

6/29/2006 12:57:00 PM

0

OK. Here is the straight dope. I'm not the only one with the
mainframe/pc-network disconnect. FTP has the same disconnect. WHEN I
run FTP from the mainframe and get the data from network, everything is
ok. OS/390 TCP/IP understands all the CR/LF stuff and deals with it
properly.

On the other side is FTP on the network. This is mainly Unix based.
(We all know that DOS is just a dumbed down Unix variant.) It operates
in a LF or CR/LF world. When it is talking to the mainframe, it
doesn't know that. Sure, I setup the ASCII/EBCDIC notification (TYPE
A), but it still doesn't deal with the trailing characters.

I really only have two alternatives here: 1) live with the extra byte
on the mainframe side, or 2) live without the CR/LF on the network
side. 1) is not a possibility. So 2) will have to be it. Since the
data created on the PC side is extracted from an Excel spreadsheet, I
have the data in a usable format. So the text file is not for general
use.

I hope someone else can make use of this information, or correct me
where I am wrong.

Have a good one, all!
dvn

dkmd_nielsen@hotmail.com wrote:
> I'm sure you don't get too many mainframe related questions. First the
> code, then my blather.
>
> f = Net::FTP.open("wouldntyou.liketoknow.com","anonymous")
> f.chdir("'#{prj.mainframe_prefix}'")
> f.site("LOCSITE BLOCKS BLKSIZE=0 LRECL=124 RECFM=FB PRIMARY=500
> SECONDARY=500")
> f.puttextfile("#{prj.networkfolder}\\#{prj.deptrun}_flc_cards.txt","FLC")
> f.site("LOCSITE BLOCKS BLKSIZE=0 LRECL=60 RECFM=FB PRIMARY=500
> SECONDARY=500")
> f.puttextfile("#{prj.networkfolder}\\#{prj.deptrun}_flc_cards.txt","PRTY")
> f.close
>
>
> I'm attempting to ftp a network based text file to the mainframe (ascii
> to ebcdic). Everything operates without error, but only the first
> record of the file is transmitted. I added a code block to the
> puttextfile function and a puts to display everything being sent. Yep,
> just one line. Each text line does have a CRLF at the end. I tried it
> without the CRLF. That was no go, too.
>
> I tried setting TYPE A and then using just put. put sent the file
> binary, anyway. But atleast the binary gobbldee gook appears to have
> sent all the records.
>
> Your thoughts are appreciated,
> dvn - I've googled everything I can possibly think of.
> dvn

Frank Swarbrick

6/30/2006 2:43:00 AM

0

dkmd_nielsen@hotmail.com wrote:
> OK. Here is the straight dope. I'm not the only one with the
> mainframe/pc-network disconnect. FTP has the same disconnect. WHEN I
> run FTP from the mainframe and get the data from network, everything is
> ok. OS/390 TCP/IP understands all the CR/LF stuff and deals with it
> properly.
>
> On the other side is FTP on the network. This is mainly Unix based.
> (We all know that DOS is just a dumbed down Unix variant.) It operates
> in a LF or CR/LF world. When it is talking to the mainframe, it
> doesn't know that. Sure, I setup the ASCII/EBCDIC notification (TYPE
> A), but it still doesn't deal with the trailing characters.
>
> I really only have two alternatives here: 1) live with the extra byte
> on the mainframe side, or 2) live without the CR/LF on the network
> side. 1) is not a possibility. So 2) will have to be it. Since the
> data created on the PC side is extracted from an Excel spreadsheet, I
> have the data in a usable format. So the text file is not for general
> use.
>
> I hope someone else can make use of this information, or correct me
> where I am wrong.
>
> Have a good one, all!

I've worked a lot with transfering text files to and from a VSE
mainframe. I imagine an os/390 (z/OS) mainframe is quite similar.
Let's look at how this works.

(All of the below refers to ASCII text mode, not binary mode.)

First of all, FTP is an ASCII based protocol when transmitting text.
Secondly, no matter the source (Unix, PC, mainframe or whatever), the
end-of-line delimiter *IS* CR/LF. When a Unix machine transmits a file,
even to another Unix machine, it ads an LF after ever CR delimited line.
When receiving a text file it strips out the LF before storing the
file to the file system.

Mainframe is similar, somewhat. When sending a file in ASCII text mode
the mainframe FTP client or server does the following:
- Reads the record from the mainframe file
- Translates the record from EBCDIC to ASCII
- Appends an ASCII CR/LF
- Transmits the line (or ads it to a buffer to be transmitted when it's
full)

Receiving is similar:
- Receive a block of data
- Search for CR/LF
- When found, translate all data leading up to it from ASCII to EBCDIC
- Write the record to the file and throw away the CR/LF

Now I'm sure z/OS, like VSE, has quite a few options. One option is to
expect fixed length records with *no* delimiter. In this case the
mainframe (assuming a PC -> mainframe transfer) simply writes ever X
number of translated bytes as a record. But if the file actually *does*
have CR/LF delimiters then you end up writing those to the mainframe
file as well. You can recognise this fairly easy if the first two
characters of record two look like the EBCDIC equivalents of CR and LF.

I'm guessing this is your problem, but I can't be sure. Certainly there
must be someone at your site who is knowledgable about mainframe FTP and
all of its little quirks.

Good luck!

Frank