LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-24-2002, 05:28 PM   #1
dalraidia
Member
 
Registered: Dec 2002
Location: Tallahassee, Florida
Posts: 30

Rep: Reputation: 15
converting MS-DOS files to Linux


I have a cdrom with some C++ programs on it that I want to compile with gcc. I can mount the cdrom OK but gcc complains about the format. I assume this has to do with LF's and CR's and that sort of stuff. Is there an automatic conversion program that I can use to convert to a format that gcc likes??

John
 
Old 12-24-2002, 05:49 PM   #2
blinux1
Member
 
Registered: Nov 2002
Location: Pennsylvania
Distribution: Mandrake 9.1 and Redhat 9
Posts: 144

Rep: Reputation: 15
mount cdrom manual?

you can mount the cd-rom manually, using:

mount -t iso9660 /dev/scd0 /mnt/cdrom

command filesystem_type_flag filesystem device(SCSI) mount_dir

Then you can just load the programs from your cdrom to a local directory. Something tells me that this isn't quite the answer you were looking for, but i hope it helps.
 
Old 12-24-2002, 05:50 PM   #3
blinux1
Member
 
Registered: Nov 2002
Location: Pennsylvania
Distribution: Mandrake 9.1 and Redhat 9
Posts: 144

Rep: Reputation: 15
If you have KDevelop, you might want to try loading your c++ programs from there
 
Old 12-24-2002, 06:11 PM   #4
dalraidia
Member
 
Registered: Dec 2002
Location: Tallahassee, Florida
Posts: 30

Original Poster
Rep: Reputation: 15
No, no. The problem as I understand it is that MS-DOS text files have a CR/LF at the end of each line, and in Unix there is only a LF at the end of each line. I suppose I could write something to do the conversion, but I thought there might be a utility already on there to do it.

John
 
Old 12-24-2002, 06:21 PM   #5
J_Szucs
Senior Member
 
Registered: Nov 2001
Location: Budapest, Hungary
Distribution: SuSE 6.4-11.3, Dsl linux, FreeBSD 4.3-6.2, Mandrake 8.2, Redhat, UHU, Debian Etch
Posts: 1,126

Rep: Reputation: 58
Maybe there is a tool, which I do not know, but I have a tip:
Have you tried google search?
I gave it a try with the following keywords:
convert CR LF linux dos
Google found 9510 pages in 0.16 seconds. And right the first seemed to be just what you need. Try it and see.
 
Old 12-24-2002, 06:28 PM   #6
dalraidia
Member
 
Registered: Dec 2002
Location: Tallahassee, Florida
Posts: 30

Original Poster
Rep: Reputation: 15
Oh yes, I did try Google, and found quite a few programs. The question is whether or not such a program ALREADY exists in RH8.0 or whether I have to go get one somewhere else. (I thought it might be in DOSUTILS, but no such luck. :-(

John
 
Old 12-24-2002, 06:43 PM   #7
J_Szucs
Senior Member
 
Registered: Nov 2001
Location: Budapest, Hungary
Distribution: SuSE 6.4-11.3, Dsl linux, FreeBSD 4.3-6.2, Mandrake 8.2, Redhat, UHU, Debian Etch
Posts: 1,126

Rep: Reputation: 58
OK I read that page found by Google here:
http://www.leuf.net/cgi/wikidn?WikiWaySources

It deals with the same problem that you are faced now: porting C source code from DOS to Linux.

From that page I learned that there is a standard unix command, which should be available on all Linux distros, too:

dos2unix

(I checked: I have it in my SuSe distro)

To find out if you have it, type:
type dos2unix
in a terminal window.

To find out how it works, type:
dos2unix --help
or:
man dos2unix
in a terminal window.
 
Old 12-24-2002, 07:01 PM   #8
dalraidia
Member
 
Registered: Dec 2002
Location: Tallahassee, Florida
Posts: 30

Original Poster
Rep: Reputation: 15
Yup. Got it. Exactly what I was looking for! (And thanks for the tip about using "type" -- didn't know about that).

John
 
Old 12-24-2002, 07:15 PM   #9
J_Szucs
Senior Member
 
Registered: Nov 2001
Location: Budapest, Hungary
Distribution: SuSE 6.4-11.3, Dsl linux, FreeBSD 4.3-6.2, Mandrake 8.2, Redhat, UHU, Debian Etch
Posts: 1,126

Rep: Reputation: 58
I was pleased to help you.

Bye
 
Old 12-25-2002, 06:59 PM   #10
odat
LQ Newbie
 
Registered: May 2001
Posts: 29

Rep: Reputation: 15
Umm, my 2 cents.
1. dos2unix isn't on my personal machine (older Mandrake)
it's a perl script on one FreeBSD system I use, so I
installed that in usr/local/bin (no man pages though)
The classic Un*x/Linux commands for seeing a file are:
"cat", "more", and "less". "type <file>" won't work everywhere.
"type" is/was the name of a similar MS-DOS command.
 
Old 12-25-2002, 07:49 PM   #11
J_Szucs
Senior Member
 
Registered: Nov 2001
Location: Budapest, Hungary
Distribution: SuSE 6.4-11.3, Dsl linux, FreeBSD 4.3-6.2, Mandrake 8.2, Redhat, UHU, Debian Etch
Posts: 1,126

Rep: Reputation: 58
My '2 cents':
1. I only hoped that he had the dos2unix binary in his path. And he had. So, where is the problem?
2. I would never use "cat", "more" or "less" to find a binary (or a script), since these would list the contents of the file rather than simply saying where it is. (To see the difference, try the two commands e.g. when logged-in into a remote machine via a slow modem connection).
You are wrong when saying 'type is/was the name of a similar MS-DOS command':
The unix 'type' command and the MS-DOS 'type' command are not similar; they establish two completely different tasks: the unix 'type' command prints out the location of a binary if it is in the path, while the MS-DOS 'type' command lists the contents of the file, if found.
If I was to find an alternative to the unix 'type' command, I would recommend the 'which' command that establishes the same task (however the use of the latter is deprecated on SuSe, it is only an alias to 'type -p')
If dos2unix was not likely to be a binary in his path, I would have rather recommended him the command 'find / -name 'dos2unix'' , but this would have resulted in a very long search time, which seemed (and proved) to be unnecessary in this case.

Last edited by J_Szucs; 12-25-2002 at 07:55 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
SED - Converting UNIX to DOS file aurelio26 Linux - Newbie 7 04-09-2008 12:15 AM
For people how want to play WMA files without converting MP3 files waelaltaqi Linux - Software 15 11-17-2005 08:30 AM
converting text file from linux to ms dos Berhanie Linux - Newbie 4 12-24-2003 10:54 PM
Converting Shorten files using Linux haystacs Linux - Software 5 05-08-2003 11:47 AM
Are linux scripts just as simple as dos batch files? neeyo Linux - General 4 07-21-2002 11:42 AM


All times are GMT -5. The time now is 05:56 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration