Why is your file named binary1.txt? That is a highly misleading name.

If you don't know the format of your binary file and have no documentation by the person who provided you the file, you have to find out the data format yourself. This is not an easy task for a beginner in programming, but on the other hand, it does not require that much programming and much much more thinking and guess work.

The first step is to find out what pieces of data could be in the file and if there are repeating structures in the file. Once you have determined these boundaries, you can then look further.

You mentioned an EBCDIC data structure earlier. Maybe you can find out with a printout of the hexdump in one hand, and a colored marker in the other what parts belong where.

Byte Field Code 1 - 11 Record header 12 Type of activation (1) BIN 13 Type of message (2) BIN 14 - 19 Name of the process EBCDIC 20 - 25 Name of the command EBCDIC 26 Type of terminal (3) BIN 27 Address of terminal BIN 28 - n Complementary message EBCDIC

So, you could mark the bytes 0 to 10 with one color, marking them as the header.

The byte number 12 would be the type of activation and the byte number 13 would be the message type.

The name of the process would be a 5 byte string, but the bytes are encoded in EBCDIC. You can find a translation table from EBCDIC to ASCII online. Use that table to translate the text to something human readable and to understand the data.

Starting with byte 28, there is more EBCDIC encoding another message. Repeat the previous process, using the same colours for the same parts of the message.


In reply to Re^5: how to extract original string from binary files? by Corion
in thread how to extract original string from binary files? by swapy345

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.