File FTP to Unix from Mainframes.

Hi I have got one file FTPd from mainframe in an ASCII format in Unix environment.

If I have to deduce record width within this file, each approach we are finding different record width.

head -1 filename | wc -m
awk '{print length($0)}' filename ... lists record width for all records.
sed -n '1np' filename | wc -m

Each of these 3 approaches I get different count. It is very much clear file which got transferred from Mainframes is not correctly got FTPd.

Has anyone faced this problem before, & can help me?

Thanks in advance.

Just a thought, when the data comes over from a mainframe, won't it be in EBCDIC encoding? You will probably have to convert this to ASCII before you can do anything with it.

If you do a search of all forums for "ftp mainframe" you should find several threads about transferring fixed record length files.

My team is receiving file from mainframes, for which we are not writing FTP command in a JCL.
My question is how come 3 different commands which help in estimating no of chars in record give different output?
Since any normal ASCII file, the command I mentioned produces the same counts.

The file which we receive is in ASCII, because when I cat it, I can see the ASCII business contents in it.

You don't provide much info, but I will make a guess based the little info I have. Those files are not organized as a collection of lines of ascii characters. A line will have a max length and it must be terminated by a newline character. Files like this are the only files those commands are designed to work with. So each command is screwing up in a slightly different manner.

Yes you are right Perderabo, the file which we received from mainframes had these weird '^@' chars, which is not detectible by simple cat command. It could be only seen by cat -v.