LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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
  Search this Thread
Old 01-19-2003, 10:55 AM   #1
MasterC
LQ Guru
 
Registered: Mar 2002
Location: Salt Lake City, UT - USA
Distribution: Gentoo ; LFS ; Kubuntu ; CentOS ; Raspbian
Posts: 12,613

Rep: Reputation: 69
How would one convert a file into binary?


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?
 
Old 01-19-2003, 12:38 PM   #2
Edward78
Member
 
Registered: Jul 2002
Distribution: OpenSuSE 11
Posts: 441

Rep: Reputation: 30
You can't convert a text file into binary. Why would you want to? You should link that to a linux howto page.
 
Old 01-19-2003, 12:44 PM   #3
MasterC
LQ Guru
 
Registered: Mar 2002
Location: Salt Lake City, UT - USA
Distribution: Gentoo ; LFS ; Kubuntu ; CentOS ; Raspbian
Posts: 12,613

Original Poster
Rep: Reputation: 69
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
 
Old 01-19-2003, 12:47 PM   #4
MasterC
LQ Guru
 
Registered: Mar 2002
Location: Salt Lake City, UT - USA
Distribution: Gentoo ; LFS ; Kubuntu ; CentOS ; Raspbian
Posts: 12,613

Original Poster
Rep: Reputation: 69
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
 
Old 01-19-2003, 10:47 PM   #5
MasterC
LQ Guru
 
Registered: Mar 2002
Location: Salt Lake City, UT - USA
Distribution: Gentoo ; LFS ; Kubuntu ; CentOS ; Raspbian
Posts: 12,613

Original Poster
Rep: Reputation: 69
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
 
Old 01-20-2003, 07:58 PM   #6
Grim Reaper
Member
 
Registered: Apr 2002
Distribution: Gentoo 2006.0 AMD64
Posts: 399

Rep: Reputation: 30
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
 
Old 01-20-2003, 08:05 PM   #7
MasterC
LQ Guru
 
Registered: Mar 2002
Location: Salt Lake City, UT - USA
Distribution: Gentoo ; LFS ; Kubuntu ; CentOS ; Raspbian
Posts: 12,613

Original Poster
Rep: Reputation: 69
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
 
Old 01-21-2003, 08:10 AM   #8
qanopus
Senior Member
 
Registered: Jul 2002
Location: New York
Distribution: Slackware
Posts: 1,358

Rep: Reputation: 45
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.
 
Old 01-21-2003, 10:50 PM   #9
oulevon
Member
 
Registered: Feb 2001
Location: Boston, USA
Distribution: Slackware
Posts: 438

Rep: Reputation: 30
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.
 
  


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

LinuxQuestions.org > Forums > Non-*NIX Forums > General

All times are GMT -5. The time now is 01:42 AM.

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