LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-14-2013, 05:43 AM   #1
pingu
Senior Member
 
Registered: Jul 2004
Location: Skuttunge SWEDEN
Distribution: Debian preferably
Posts: 1,350

Rep: Reputation: 127Reputation: 127
File format changed to DOS after copying between Linux boxes?


In short: I copy a text-file in Linux format from opensuse1 to opensuse2.
The file format is changed to DOS!

Details:
I have 2 servers running OpenSuse 12.2, one for testing one production.
I only use Linux myself on all my computers. (Home: LMDE, laptop: Mint14 - both with Mate desktop.)
What I do is write a few bash scripts on suse-test, try them out and then transfer them to suse-prod.
I have transferred the files different ways - sometimes using scp, or sometimes with copy-paste by mouse-copying (mark+middle-click) from nano on terminal suse-test to nano on terminal suse-prod. Also sometimes I open the test-file with Kate on my laptop using fish://, then I copy (middle-click) in nano (as root) on terminal suse-prod or save to my homedir on suse-prod directly with Kate.
All of these ways normally works fine, about a dozen files transferred this way.
But the file I transferred yesterday ended up on suse-prod in DOS format!

Problem in itself is fixed, no problem converting to Unix format, but I'm so curious about how / why this happened?
 
Old 03-14-2013, 07:14 AM   #2
manu-tm
Member
 
Registered: May 2008
Location: France
Distribution: Ubuntu, Debian
Posts: 343

Rep: Reputation: 43
Do you mean newlines inside file were changed from '\n' into '\r\n' ?
 
Old 03-14-2013, 07:20 AM   #3
pingu
Senior Member
 
Registered: Jul 2004
Location: Skuttunge SWEDEN
Distribution: Debian preferably
Posts: 1,350

Original Poster
Rep: Reputation: 127Reputation: 127
Yes - well, it's the different linebreaks that causes problems although it is not what I checked.
Symptom: When executing the file I got error
Code:
bash: /home/peterh/dl_trans/sbin/dl_control: /bin/bash^M: bad interpreter: No such file or directory
The character I put in bold is what shows it's wrong kind.
I then opened the file with nano, got a message "converted from DOS format".
I did not get that message when opening original file.
My solution was simply to save again in nano, and remove the "DOS Format".
 
Old 03-14-2013, 07:30 AM   #4
manu-tm
Member
 
Registered: May 2008
Location: France
Distribution: Ubuntu, Debian
Posts: 343

Rep: Reputation: 43
Text editors usually have an option to save files using Unix vs DOS formated newlines (ie linebreaks) so it could have happened like that. Do you remember how you transfered the file?

Last edited by manu-tm; 03-14-2013 at 10:30 AM.
 
Old 03-14-2013, 07:42 AM   #5
pingu
Senior Member
 
Registered: Jul 2004
Location: Skuttunge SWEDEN
Distribution: Debian preferably
Posts: 1,350

Original Poster
Rep: Reputation: 127Reputation: 127
Not sure, I opened it with kate in my computer using fish://
Then I either chose "save as" in Kate, or copied and pasted in nano on suse-prod.
Kate does not have an option (that I can see) to save in other format, I have used all these methods earlier without any problem.
I have recently updated my laptops system though, wonder if something has changed - mainly thinking about the fish-protocol, will test later when I have more time.
 
Old 03-14-2013, 07:52 AM   #6
pingu
Senior Member
 
Registered: Jul 2004
Location: Skuttunge SWEDEN
Distribution: Debian preferably
Posts: 1,350

Original Poster
Rep: Reputation: 127Reputation: 127
Very crazy this...
Checking what I did, I'm pretty sure I saved it in Kate directly to my homedir on suse-prod.
When I got that error message, I scp'd directly from suse-test to suse-prod.
On suse-test the file executed fine, no "DOS format" message in nano. On suse-prod it didn't execute because of the linebreaking, message "DOS format" in nano.
HOWEVER! Doing the same with other bash-files this does not happen! They execute fine & re NOT in DOS format!
 
Old 03-14-2013, 08:05 AM   #7
eSelix
Senior Member
 
Registered: Oct 2009
Location: Wroclaw, Poland
Distribution: Arch, Kubuntu
Posts: 1,281

Rep: Reputation: 320Reputation: 320Reputation: 320Reputation: 320
In Kate you have it in menu "Tools"/"End of line" for current document. Check also "Settings"/"Open/Save" on "General" tab for deafult setting and on "Modes&Filetypes" tab where are individual settings based on type of file you are opening.

Can you write what is filename with extension of this file?

Last edited by eSelix; 03-14-2013 at 08:07 AM.
 
Old 03-14-2013, 09:28 AM   #8
pingu
Senior Member
 
Registered: Jul 2004
Location: Skuttunge SWEDEN
Distribution: Debian preferably
Posts: 1,350

Original Poster
Rep: Reputation: 127Reputation: 127
Quote:
Originally Posted by eSelix View Post
In Kate you have it in menu "Tools"/"End of line" for current document. Check also "Settings"/"Open/Save" on "General" tab for deafult setting and on "Modes&Filetypes" tab where are individual settings based on type of file you are opening.
I have never ever touched those settings!
File on suse-test has correct line endings.
Default setting for EOL is "DOS/Windows", but "Automatic eol detection" is marked.
And, as I mentioned, this has never happened before - and it did happen when copying via scp!
Now I can't recreate it???

The file has no extension, I don't use that for bash scripts.
 
Old 03-14-2013, 02:26 PM   #9
eSelix
Senior Member
 
Registered: Oct 2009
Location: Wroclaw, Poland
Distribution: Arch, Kubuntu
Posts: 1,281

Rep: Reputation: 320Reputation: 320Reputation: 320Reputation: 320
If you had "DOS/Windows" as default setting, then you probably did copy (from Unix EOL) and paste to newly created by kate file which did conversion to satisfy your default Windows EOL. The "Automatic detection" is only used for opening files, to set line ending properly in case you want to append some new lines. But by "scp", I think its impossible, especially you can't recreate it.
 
1 members found this post helpful.
Old 03-14-2013, 02:45 PM   #10
pingu
Senior Member
 
Registered: Jul 2004
Location: Skuttunge SWEDEN
Distribution: Debian preferably
Posts: 1,350

Original Poster
Rep: Reputation: 127Reputation: 127
I can't recreate it with Kate either...

You have a good thought there, and very good to know that Kate's "Automatic detection" is only used for opening files not creating, but still no go.
You see, I never created a new file & pasted to it, I just saved it to a new location. While you might think this is actually the same as creating a new file, it doesn't happen with any other file. They always keep the original linebreak setting.
And what's more, I've done this many many times before, never had this problem.
Plus! It did happen when I scp'd too!

This is all crazy, I have tried so many ways now but I simply can't recreate the error.
Well, of course that's good in one way, I just wander what the h*ck went wrong this morning. (And before you ask: YES I had had my coffee I WAS awake! )
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
In DOS fdisk, format, sys, copy files, edit autoexec - In linux? by hand? pentalive Linux - General 19 10-16-2013 08:53 AM
Linux File Server storing data in DOS/WINDOWS format FineArt0104 Linux - Server 7 12-29-2011 04:58 AM
File format messed up when copying Metropolis Linux - General 15 08-02-2009 11:52 PM
Command to convert dos file to a unix format sathish80 Linux - Newbie 1 03-22-2006 11:32 PM
Why do file names keep getting changed to dos 8.3 format on my usb drive? firehawk256 Linux - Newbie 1 02-25-2005 03:32 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:26 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration