Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Creating data delimited by ASCII code 1 Post 303036243 by jim mcnamara on Thursday 20th of June 2019 08:16:30 AM
Old 06-20-2019
Pure shell script does NOT work at all well with binary data. The main reason is that binary data will have the ASCII 0 character. For shell, this character marks the end of a string. I would try using the dd command instead. For a start on this.

1. What OS do you have
2. are the binary "fields" all exactly the same length, e.g., pick one: 4 bytes, 8 bytes, etc.
3. can you work with writing simple C code? or perl? This may be another option for you.
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Convert Binary data to ascii data

Friends, I've tried on solaris, but I could n't get ascii data dd if=binaryinputfile bs=1 skip=3800 count=4 | od -t u4 output : INDBU3:/usr/users/FTAMUSER/kk $ dd if=SMP20041006173649188151 bs=1 skip=3800 count=4 | od -t u4 4+0 records in 4+0 records out 0000000 0000000000 0000004... (4 Replies)
Discussion started by: krishna
4 Replies

2. UNIX for Dummies Questions & Answers

Creating flat text file (ASCII)

Hi everybody. I need help and I hope someone is willing to help me out here. My wholesale company is currently moving to new software. The old software is running on a UNIX platform. We need to migrate data from the UNIX system, but our former software provider refuses to assist the data... (5 Replies)
Discussion started by: Wdonero
5 Replies

3. Shell Programming and Scripting

Check whether a given file is in ASCII format and data is tab-delimited

Hi All, Please help me out with a script which checks whether a given file say abc.txt is in ASCII format and data is tab-delimited. If the condition doesn't satisfy then it should generate error code "100" for file not in ASCII format and "105" if it is not in tab-delimited format. If the... (9 Replies)
Discussion started by: Mandab
9 Replies

4. Shell Programming and Scripting

how to check the file data type(ascii or binary)

hi i am receiving a file from one system , i have to verify the format of the file data i.e whether the data is in acii format or binary format, please help thanks in advance satya (1 Reply)
Discussion started by: Satyak
1 Replies

5. UNIX for Dummies Questions & Answers

Sorting data in an ASCII file

Hi,,, is there anyway to sort the data that I have on an ASCII file, using unix? :confused::confused::confused: Thanks (2 Replies)
Discussion started by: cosmologist
2 Replies

6. Shell Programming and Scripting

how to convert data from ASCII to Packed Decimal

Hi All, Please let me know if it is possible to convert data from ASCII to Packed Decimal through Unix? Basically we have ASCII file with numeric data we want to convert that files data to Packed decimal format to send it to main frame. Please let me know if we can do it through unix script.... (1 Reply)
Discussion started by: aloktiwary
1 Replies

7. Shell Programming and Scripting

Import ASCII 28 delimited text file

I have an ASCII 28 delimited text file(non-printable delimiter) with 4 columns along with the header.I need to open this text file in Excel or any other tool to view each column content. Please help.. Thanks (6 Replies)
Discussion started by: aneeta13
6 Replies

8. UNIX for Advanced & Expert Users

Conversion of data - ebcdic to ascii

Hi, I want to convert ebcdic values to ascii values. Are there anyany specific c++ libraries with g++ compiler, which can do it ? gcc version 4.1.2 20080704 (Red Hat 4.1.2-54) (0 Replies)
Discussion started by: tostay2003
0 Replies

9. Shell Programming and Scripting

Bash - binary data to ascii code

Hello, With bash-script (ubunto server) I'm trying to read a binary file and, for each character, give back its ascii code (including extended ascii). For example: HEX => ASCII => PRINT f5 => 245 => õ 50 => 80 => P To load the binary file into a variable I tried in this way: ... (2 Replies)
Discussion started by: math4
2 Replies

10. Homework & Coursework Questions

ASCII comma-delimited

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Hi Guys, I am new on the scripting world and would like ask for help if you can. Here are my questions... (1 Reply)
Discussion started by: mahiwaga
1 Replies
TYPERULES(5F)															     TYPERULES(5F)

NAME
typerules - HylaFAX file type identification and conversion rules DESCRIPTION
Only three types of files are accepted by the HylaFAX server for transmission as facsimile: POSTSCRIPT(R) files, PDF files, and TIFF Class F (bilevel Group 3-encoded) files. All other types of files must be converted to one of these three formats. The facsimile submission program applies a set of rules against the contents of each input file to identify the file's type and to figure out how to convert the file to a format that is suitable for transmission. These rules are stored in the file /usr/lib/fax/typerules, an ASCII file that is pat- terned after the /etc/magic file used by the System V file(1) program. However, there are significant differences, noted below. Type rules work by matching data patterns in a file; typically patterns that appear in the first few bytes of the file (i.e. magic num- bers). There are two types of rules, primary rules and secondary rules. Secondary rules specify additional rules to apply after a primary rule has been matched. When secondary rules are used, rule scanning continues up to the next primary type rule in the file. Each rule consists of a set of whitespace-separated fields: offset datatype match result command If an line is terminated wth a backslash character, the entry is continued on the next line with any leading whitespace characters com- pressed to a single space. Comments are marked with the ``#'' character; everything from to the end of the line is discarded. Secondary rules have a ``>'' character in the first column of the line; primary rules do not. The fields in each rule entry are: offset The byte offset in the file at which data should be extracted and compared to a matching string or value. datatype The type of data value to extract at the specified offset for comparison purposes; one of: ``byte'' (8 bit unsigned number), ``short'' (16 bit unsigned number), ``long'' (32 bit unsigned number), ``string'' (an array of bytes), ``istring'' (a case-insen- sitive array of bytes), or ``ascii'' (an array of ASCII-only bytes). match The value and operation to use in matching; the value used is based on the datatype field. If value is ``x'', then it is inter- preted to mean match anything; otherwise the following operators are supported (where data is the value extracted from the file and value is specified in the match field) except for types ``string'', ``istring'', and ``ascii'': = data == value != data != value > data > value < data < value <= data <= value >= data >= value & (data & value) == value ! (data & value) != value ^ (data ^ value) != 0 If no operation is specified then ``='' is used. For ``string'', ``istring'', and ``ascii'' no operator is allowed; the implicit operation is always ``=''. In these cases, the field is terminated by a tab or end of line, not by ``#''. Characters in the field have their literal value; there are no C-style character escapes. result One of ``ps'', ``tiff'', or ``error'' (case insensitive). The first two results specify whether the rule generates a POSTSCRIPT file or a TIFF/F file (Group 3-encoded bilevel data), respectively. The ``error'' result indicates that a file is unsuitable for transmission and, if supplied for transmission, should cause the job to be aborted with the command field used in an error mes- sage. command A command description that is expanded and passed to the shell to convert the input file to the result format (suitable for send- ing as facsimile). Before the string is passed to the shell, it is scanned and the following ``%'' escape codes are substituted for: %i input file name %o output file name %r output horizontal resolution in pixels/mm %R output horizontal resolution in pixels/inch %v output vertical resolution in lines/mm %V output vertical resolution in lines/inch %f data format, ``1'' for 1-d encoding or ``2'' for 2-d encoding %w page width in pixels %W page width in mm %l page length in pixels %L page length in mm %s page size by name %F the directory where HylaFAX filter programs reside %<x> the <x> character (e.g. ``%%'' results in ``%'' See below for example uses of these codes. EXAMPLES
The following rules are used to match the formats that are handled directly by the server: #offset datatype match result command 0 string %! ps # POSTSCRIPT 0 string %PDF ps # POSTSCRIPT by Ghostscript 0 short 0x4d4d tiff # big-endian TIFF 0 short 0x4949 tiff # little-endian TIFF These rules are used to process the ASCII version of IRIS Inventor database files while blocking the transmission of the binary format variant: #offset datatype match result command 0 string #Inventor V error IRIS Inventor file >15 string binary error binary IRIS Inventor file >15 string ascii ps %F/textfmt -fCourier-Bold -p11bp -U -q >%o <%i This rule is typically the last entry in the file and is used to convert all unmatched ASCII data files to POSTSCRIPT: #offset datatype match result command 0 ascii x ps %F/textfmt -fCourier-Bold -p11bp -U -q >%o <%i NOTES
It is much better to convert data that is to be transmitted to POSTSCRIPT because this data format permits the facsimile server to do the final imaging according to the optimal transfer parameters (resolution, binary encoding, etc.). It might be better to allow secondary rules to augment a primary rule rather than just replace them. This would allow, for example, com- mand line options to be selected based on file type. SEE ALSO
sendfax(1), hylafax-client(1) May 12, 1993 TYPERULES(5F)
All times are GMT -4. The time now is 05:29 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy