User avatar
Pwl2
Posts: 22
Joined: Mon Mar 23, 2015 7:04 am
Location: Warwickshire

File transfer problem

Tue May 26, 2015 7:11 pm

I am trying to transfer a text file (using Filezilla in SFTP mode) created in notepad on Win 7 to a Pi running Rasbian, that is to be processed for use by fortune. The file looks fine on Win and under nano on the Pi

Code: Select all


%
quote 1
%
quote 2
%
but when I run

Code: Select all

strfile -c % test test.dat
I tells me there is only one line the length of the file and when I run fortune the cookie is all the file.
If I create the file in nano it works as expected in strfile / fortune bur on transfer and editing in notepad I get

Code: Select all


%quote 1%quote 2%
I have tried transferring as asciii, binary and using a zip file. Any Ideas as to what I have wrong? I know fortune is trivial but the underlying problem concerns me.

Paul
Pwl2

User avatar
kusti8
Posts: 3439
Joined: Sat Dec 21, 2013 5:29 pm
Location: USA

Re: File transfer problem

Tue May 26, 2015 7:34 pm

I would think it's because windows uses different ways to signify a new line. Use something like notepad++ and switch to Unix new line.
There are 10 types of people: those who understand binary and those who don't.

Joe Schmoe
Posts: 4277
Joined: Sun Jan 15, 2012 1:11 pm

Re: File transfer problem

Tue May 26, 2015 8:04 pm

Yeah, it certainly sounds like yet another iteration of the DOS vs. Unix line endings problem.

There are tools called "dos2unix" and "unix2dos" that supposedly handle this, but it's not really worth the hassle. (To put it another way, these tools have never really worked well for me...)

Anyway, the first thing to do is to load the file up into vi (vim);

Code: Select all

vi file
Then do:

Code: Select all

:se ff?
That will tell you the fileformat. Now, assuming that says "dos", then you can do:

Code: Select all

:se ff=unix
And finally, press ZZ (that's right, two capital Zs) to save and exit the file.
That will convert it to unix format. Then it should work...
And some folks need to stop being fanboys and see the forest behind the trees.

(One of the best lines I've seen on this board lately)

User avatar
Pwl2
Posts: 22
Joined: Mon Mar 23, 2015 7:04 am
Location: Warwickshire

Re: File transfer problem

Fri May 29, 2015 9:48 am

Thanks. It was the line ending problem. I thought ASCII mode FTP took care of that.

Pwl2
Pwl2

User avatar
Jednorozec
Posts: 809
Joined: Sun Nov 24, 2013 2:17 pm
Location: Deposit, NY

Re: File transfer problem

Fri May 29, 2015 10:59 am

Pwl2 wrote:Thanks. It was the line ending problem. I thought ASCII mode FTP took care of that.
FTP text mode should take care of that but filezilla seems to screw up. Try http://winscp.net/eng/index.php - it's always worked well for me.
The most important leg of a three legged stool is the one that's missing.
It's called thinking. Why don't you try it sometime?

Return to “General discussion”