1827481 Members
2298 Online
109965 Solutions
New Discussion

FTP query

 
SOLVED
Go to solution
Tim O'Connell
Regular Advisor

FTP query

If I create a file in Unix which has for example 5 lines. When I go to a pc & ftp, get this file it ends up with 6 lines on the pc - an extra blank line is inserted at the end. Is there anyway of avoiding this or is there something like sed that could remove the last line on the pc. Its causing me problems passing this file into software which doesn't like a blank line. Hope someone has come across this.

Thanks,

Tim
11 REPLIES 11
Ralph Grothe
Honored Contributor

Re: FTP query

try the transfer in bin mode
Madness, thy name is system administration
Arunvijai_4
Honored Contributor

Re: FTP query

Hi Tim,

How did you transfer the file between PC and UNix ? Try to use ascii mode for text files.

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Tim O'Connell
Regular Advisor

Re: FTP query

Thanks for the replies.
I have transferred the file as Ascii but whin I open it in Notepad or Wordpad it has an extra blank line at the end. Bin doesn't work.

Thanks,

Tim
Steven E. Protter
Exalted Contributor

Re: FTP query

Tim,

The ftp client for Windows is very simple and it can't tell binary from ascii.

If you use it you must know if the file is ascii or binary before you ftp.

There is an HP-UX command called file that will help you determine this.

file fileman.ddr

Will say binary or ascii.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Andrey Tumanov
Frequent Advisor

Re: FTP query

Are you sure that you don't have that extra blank line or space in the file? Try
# vis -n
command to check it.

Andrey
Ralph Grothe
Honored Contributor

Re: FTP query

Although I never use the XP FTP client of my PC at work (only Cygwin OpenSSH) even this one has a "bin" toggle switch.
At the ftp client's prompt type "?" or "help" to get a list of available commands.
Type "status" to get your current mode displayed. If it doesn't show binary mode type "binary" (note, most of these commands may be abbreviated from the point of unambiguaty).
Often I additionaly enable hashmark printing with "hash" to better follow the load.
While in bin mode there should no attempts being made of "correcting" any ends of line or end of file.
Madness, thy name is system administration
Tim O'Connell
Regular Advisor

Re: FTP query

The file is ascii. If I create a simple file like:
1
2
3
4
on HPUX using vi and then ftp it from unix to Windows I get the file plus an extra line after the line with 4 giving a total of 5 lines in Wordpad/Notepad.

Tim
Bill Hassell
Honored Contributor
Solution

Re: FTP query

The problem is assuming that exchanging files between completely unrelated computers will be trouble free. Windows/DOS stores ASCII files as variable length records separated by CR/LF and terminated with CTRL-Z at the end of the file. Unix systems like HP-UX will create files with records delimited by just LF and nothing else. In Unix, the length of the file is known to the filesystem and the FTP program. So using BIN will always fail as the file is transferred in the native format, while ASCII mode will translate according to the rules of the target system.

The extra blank line problem is seen throughout Windows/DOS and is a feature, not a bug (smiley face). This is probably a feature of the ftp server code in the PC (no fix). Any PC program that cannot accomodate the vagaries of variable length and content files needs rewriting.


Bill Hassell, sysadmin
Tim O'Connell
Regular Advisor

Re: FTP query

Thanks for the replies. Points assigned.

Bill,

The software is third party so I will write a batch file to remove the last line.

Many Thanks,

Tim
Bill Hassell
Honored Contributor

Re: FTP query

And here a source for sed for Windows:
http://gnuwin32.sourceforge.net/packages/sed.htm

WinVi is also a very nice tool -- it actually works:

http://www.winvi.de/en/


Bill Hassell, sysadmin
Tim O'Connell
Regular Advisor

Re: FTP query

Thanks, Bill