LinuxQuestions.org
Support LQ: Use code LQCO20 and save 20% on CrossOver Office
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > General
User Name
Password
General This forum is for non-technical general discussion which can include both Linux and non-Linux topics. Have fun!

Notices

Reply
 
Thread Tools
Old 01-19-2003, 11:55 AM   #1
MasterC
Moderator
 
Registered: Mar 2002
Location: Salt Lake City, UT - USA
Distribution: Gentoo ; LFS ; Kubuntu
Posts: 12,611
Thanked: 5
How would one convert a file into binary?


[Log in to get rid of this advertisement]
Hi, figure this isn't really linux specific, so I tossed it over here.

How would someone convert their file into a binary file as shown here:
http://hr.uoregon.edu/davidrl/samba/

Click the link for "binary".



Anyone?
MasterC is offline     Reply With Quote
Old 01-19-2003, 01:38 PM   #2
Edward78
Member
 
Registered: Jul 2002
Distribution: OpenSuSE 11
Posts: 441
Thanked: 0
You can't convert a text file into binary. Why would you want to? You should link that to a linux howto page.
Edward78 is offline     Reply With Quote
Old 01-19-2003, 01:44 PM   #3
MasterC
Moderator
 
Registered: Mar 2002
Location: Salt Lake City, UT - USA
Distribution: Gentoo ; LFS ; Kubuntu
Posts: 12,611
Thanked: 5

Original Poster
Just for fun, just to be THAT geeky And most of all, to show off even more of the talents of linux.

I'll poke around and see what I can find

Cool
MasterC is offline     Reply With Quote
Old 01-19-2003, 01:47 PM   #4
MasterC
Moderator
 
Registered: Mar 2002
Location: Salt Lake City, UT - USA
Distribution: Gentoo ; LFS ; Kubuntu
Posts: 12,611
Thanked: 5

Original Poster
I've just fired an email off to David Lechnyr who's name and email address are at the top of this page.

I will let you all know if I get a response, and if so, how to do it

Cool
MasterC is offline     Reply With Quote
Old 01-19-2003, 11:47 PM   #5
MasterC
Moderator
 
Registered: Mar 2002
Location: Salt Lake City, UT - USA
Distribution: Gentoo ; LFS ; Kubuntu
Posts: 12,611
Thanked: 5

Original Poster
Proof that linux people are so nice, and ROCK! Here's the reply I recieved TODAY from David (thanks for the very prompt reply!):
Quote:
Hi Chad,

I converted the text-only version to hex using hexdump(1), and then used
sed(1) to replace the characters...

9 = 00001001
a = 00001010
b = 00001011

etc...

Although I have no plans to update it each time the main document is updated
in the future ;-) Ironically, we're so far removed from the early days of
computing that there's no direct ascii to binary translation program (at
least, not one that can process large documents that I'm aware of).

So, yes it's real, but no, it's not practical. It just seemed fitting, as
so many of these howto docs use 8 million different formats to present
themselves in, which I find to be just silly. So in a sense, it's more of a
statement of irony than anything ;-)

Cheers,
- David

----- Original Message -----
From: "Chad" <masterc@masterc.no-ip.org>
To: <david@lechnyr.com>
Sent: Sunday, January 19, 2003 10:46 AM
Subject: Question on file conversion


> Hi How did you get the Unofficial Samba HOWTO converted to Binary?
> http://hr.uoregon.edu/davidrl/samba/binary.txt
>
> Is there a tool to use, or is it just a joke
>
> Thanks
>
>
Cool eh?

Cool
MasterC is offline     Reply With Quote
Old 01-20-2003, 08:58 PM   #6
Grim Reaper
Member
 
Registered: Apr 2002
Distribution: Gentoo 2006.0 AMD64
Posts: 399
Thanked: 0
that samba document is bloody MAD!
imagine if somebody could just read that like plain english!

too bad there isn't something that will convert the entire document by just hitting go

I'll have to try what he did...hopefully i can get it to go
Grim Reaper is offline     Reply With Quote
Old 01-20-2003, 09:05 PM   #7
MasterC
Moderator
 
Registered: Mar 2002
Location: Salt Lake City, UT - USA
Distribution: Gentoo ; LFS ; Kubuntu
Posts: 12,611
Thanked: 5

Original Poster
He returned my Thank You email and included our email exchange on the homepage now! Woohoo, I'm in linuxland now!

Binary versions, he he he, that's cool.

Cool
MasterC is offline     Reply With Quote
Old 01-21-2003, 09:10 AM   #8
schatoor
Senior Member
 
Registered: Jul 2002
Location: a tiny place caled hendrik ido ambacht in the netherlands
Distribution: SuSE, debian, slackware, lfs
Posts: 1,358
Thanked: 0
Sorry for being dumb again, but that if you would take every acsii character in that file, and convert is to a "real" 0 or 1. So in psudo code :

FILE *outfile; // the output file
FILE *infile;
char text[10000];

outfile = fopen("path/to/outfile","w+");
infile = fopen("path/to/infile","r");


/*some code to dump the content
of the ascii file (infile) to a buffer
called "text" comes here
.......
.......
*/

do
{
fprinf(outfile,*text-48); // a zero is an ascii 48, I thought
text++;

}while(text);

fclose(infile);
fclose(outfile);


The above code wil ofcource not work, you I hope you get the picture.
schatoor is offline     Reply With Quote
Old 01-21-2003, 11:50 PM   #9
oulevon
Member
 
Registered: Feb 2001
Location: Boston, USA
Distribution: Slackware
Posts: 435
Thanked: 0
Somebody in the programming forum was doing this in java, although he was working on Strings, not Files. He takes each char and converts it's ascii value into binary. There's a big difference though. In java, a char is 2 bytes, while in most other languages its only 1 byte. It is strange how there isn't more support for binary while almost every programming language includes operators for bit manipulation.
oulevon is offline     Reply With Quote

Reply

Bookmarks


Thread Tools

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
How to convert binary text file from Windows marie@dk Linux - Software 2 10-12-2005 04:17 AM
How to convert a float to its binary or hex representation in Python? zero79 Programming 1 09-01-2005 11:19 AM
How to convert a float to its binary or hex representation in Python? zero79 Linux - Software 1 08-29-2005 10:30 PM
convert text file to binary excel file ust Linux - General 2 11-23-2004 03:33 AM
Convert from shell script to binary? Anon123 Linux - General 4 06-26-2004 06:53 AM


All times are GMT -5. The time now is 08:55 PM.

Main Menu
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
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration