Sponsored Content
Top Forums UNIX for Advanced & Expert Users Conversion from ASCII to binary for physical simulation code in C/C++ Post 302507413 by Cybertib on Wednesday 23rd of March 2011 07:17:25 PM
Old 03-23-2011
Ok then, that was a dummy question, and not an expert one...
Thank you for everything!

---------- Post updated at 12:17 AM ---------- Previous update was at 12:14 AM ----------

Quote:
Originally Posted by Corona688
No, they're completely different... The variables in a C program start as binary, and one of sprintf's jobs is to convert binary into ASCII. You're converting binary numbers into an ASCII string then writing the ASCII string to file.

My example doesn't convert -- it writes the variable direct, as binary. You could read them in as ASCII with with fgets and sscanf, then just write them back out raw as binary.
What about converting the old files into binary ?

"od" command seems good, but after several tests, conversion don't compress the data as expected. You gzip idea is interesting to not reach quotas, but the data need to be extracted before being treated with gnuplot in an ascii form. Using binary might much more fast, following the gnuplot documentation.

Idea?

Thank you again Smilie

Thibault
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Convert ASCII to BINARY

Here is what I did . . . . I FTP'd several *.pdf files from a web site to a UNIX server, and did not set the transfer mode to BIN, now Adobe thinks that the documents are corrupted. Is there a way to convert the *.pdf files to Binary so that Adobe can open them again. I would just re-download... (2 Replies)
Discussion started by: pc9456
2 Replies

2. Shell Programming and Scripting

ascii conversion

after converting my ebcidic file to ascii i get the following output 2097152+0 records in 1797345+1 records out Why is there a difference in number of records. Is the converson chopping off any records. All i am doing is just a conversion using the following script dd if=xaa cbs=152 ... (0 Replies)
Discussion started by: rintingtong
0 Replies

3. SCO

ascii to binary conversion in sco 5.0.5

Here is what I did . . . . I FTP'd several *.dbf zipped files from a SCO 5.0.5 server to winXP machine, and did not set the transfer mode to BIN, now when i was uncompressing these files in SCO 5.0.5 , it was giving "Bad Decode Table error. Is there a way to convert the *.dbf.Z files to Binary so... (1 Reply)
Discussion started by: sameek1211
1 Replies

4. Shell Programming and Scripting

binary to ascii

Hi, Is there a way to convert the binary file to ascii . the binary file is pipe delimited. from source the file(pipe delimited) is ftped to mainframe and from mainframe it is ftped to the unix box using binary format. Is there a way to change it back to ascii and view it? Thanks! (3 Replies)
Discussion started by: dnat
3 Replies

5. UNIX for Dummies Questions & Answers

Ascii or Binary?

Hello all, I am working with ftp servers in unix, and always I have to get and put files but I don't know exactly if I have to get or put them as an ascii or binary. Some files that I use are: .txt, .sav, .fmb, .pct, .sh, .ksh, .dat, .log. Somebody can tell me what is the difference between... (2 Replies)
Discussion started by: Geller
2 Replies

6. Shell Programming and Scripting

binary to ascii conversion

Hi, I have got a library file, created by compiling C code. The file information with "file" command, gives it a "application/x-archive" type file. I want to extract the release string of my software from this file, so that i can know which version of C files were used to create the lib. Can... (3 Replies)
Discussion started by: atulmt
3 Replies

7. Solaris

EBCDIC to ASCII Binary conversion issue on Solaris i-series Unix

Hi All, I am facing EBCDIC to ASCII Binary conversion on Solaris i-series Unix system. However this is working fine on Solaris Sparc Unix system. Input file having EBCDIC format does not work on Solaris i-series Unix system. Could you please tell me, what will be the root cause for same? (14 Replies)
Discussion started by: amodkavi
14 Replies

8. 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

9. Solaris

ASN Binary to ASCII

Dears, I need help to convert the binary file into ASCII format. Actually we have CDRs which is generated by telecom switch at this is in ASN1 format or binary format, I need to convert those binary formatted file into ASCII format using Perl, or shell scripting. Is there any way to solve... (3 Replies)
Discussion started by: PRINCESS_RORO
3 Replies

10. Shell Programming and Scripting

File conversion from Binary to ASCII though UNIX command

Hi All , I have a mainframe file which contains the data in EBCDIC format.I have downloaded this file from mainframe to windows in binary format(unreadable raw data).Now I want convert this file to ASCII format(readable format data) through Unix command.I have tried iconv but that is not working... (2 Replies)
Discussion started by: STCET22
2 Replies
SG_DECODE_SENSE(8)						     SG3_UTILS							SG_DECODE_SENSE(8)

NAME
sg_decode_sense - decode SCSI sense data SYNOPSIS
sg_decode_sense [--binary=FN] [--file=FN] [--help] [--hex] [--nospace] [--status=SS] [--verbose] [--version] [--write=WFN] [H1 H2 H3 ...] DESCRIPTION
This utility takes SCSI sense data in binary or as a sequence of ASCII hexadecimal bytes and decodes it. The primary reference for the decoding is SPC-3 ANSI INCITS 408-2005 and the most recent draft SPC-4 revision 29 which can be found at http://www.t10.org and other loca- tions on the internet. SCSI sense data is often found in kernel log files as a result of something going wrong but may just be informative. It is often shown as a sequence of hexadecimal bytes, starting with 70, 71, 72, 73, f0 or f1. Sense data could be up to 252 bytes long but typically is much shorter than that, 18 bytes long is often seen and is usually associated with the older "fixed" format sense data. The sense data can be provided on the command line or in a file. If given on the command line the sense data should be a sequence of hexa- decimal bytes separated by space. Alternatively a file can be given with the contents in binary or ASCII hexadecimal bytes. The latter form can contain several lines each with none, one or more ASCII hexadecimal bytes separated by space (comma or tab). The hash symbol may appear and it and the rest of the line is ignored making it useful for comments. OPTIONS
Arguments to long options are mandatory for short options as well. -b, --binary=FN the sense data is read in binary from a file called FN. -h, --help output the usage message then exit. -H, --hex this option is used in conjunction with --write=WFN in order to change the output written to WFN to lines of ASCII hex bytes suit- able for a C language compiler. Each line contains up to 16 bytes (e.g. a line starting with "0x3b,0x07,0x00,0xff"). -f, --file=FN the sense data is read in ASCII hexadecimal from a file called FN. The sense data should appear as a sequence of bytes separated by space, comma, tab or newline. Everything from and including a hash symbol to the end of that line is ignored. If --nospace is set then no separator is required between the ASCII hexadecimal digits in FN with bytes decoded from pairs of ASCII hexadecimal digits. -n, --nospace expect ASCII hexadecimal to be a string of hexadecimal digits with no spaces between them. Bytes are decoded by taking two hexadeci- mal digits at a time, so an even number of digits is expected. The string of hexadecimal digits may be on the command line (replac- ing "H1 H2 H3") or spread across multiple lines the FN given to --file=. -s, --status=SS where SS is a SCSI status byte value, given in hexadecimal. The SCSI status byte is related to but distinct from sense data. -v, --verbose increase the degree of verbosity (debug messages). -V, --version output version string then exit. -w, --write=WFN writes the sense data out to a file called WFN. If necessary WFN is created. If WFN exists then it is truncated prior to writing the sense data to it. If the --hex option is also given then ASCII hex is written to WFN (see the --hex option description); otherwise binary is written to WFN. This option is a convenience and may be helpful in converting the ASCII hexadecimal representation of sense data (or anything else) into the equivalent binary or a compilable ASCII hex form. NOTES
Unlike most utilities in this package, this utility does not access a SCSI device (logical unit). This utility accesses a library associ- ated with this package. Amongst other things the library decodes SCSI sense data. EXAMPLES
Sense data is often printed out in kernel logs and sometimes on the command line when verbose or debug flags are given. It will be at least 8 bytes long, often 18 bytes long but may be longer. A sense data string might look like this: f0 00 03 00 00 12 34 0a 00 00 00 00 11 00 00 00 00 00 Cut and paste it after the sg_decode_sense command: sg_decode_sense f0 00 03 00 00 12 34 0a 00 00 00 00 11 00 00 00 00 00 and for this sense data the output should look like this: Fixed format, current; Sense key: Medium Error Additional sense: Unrecovered read error Info fld=0x1234 [4660] For a medium error the Info field is the logical block address (LBA) of the lowest numbered block that the associated SCSI command was not able to read (verify or write). EXIT STATUS
The exit status of sg_decode_sense is 0 when it is successful. Otherwise see the sg3_utils(8) man page. AUTHORS
Written by Douglas Gilbert. REPORTING BUGS
Report bugs to <dgilbert at interlog dot com>. COPYRIGHT
Copyright (C) 2010-2011 Douglas Gilbert This software is distributed under a FreeBSD license. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PUR- POSE. SEE ALSO
sg_requests(sg3_utils) sg3_utils-1.32 March 2011 SG_DECODE_SENSE(8)
All times are GMT -4. The time now is 01:30 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy