Re: write binary file with struct in tcl
- From: "add" <smom2002@xxxxxxxxx>
- Date: 30 Oct 2006 18:10:06 -0800
Read the man page for binary format. Its very similar to the binary scan
options, after you have the entry in a variable you can use puts to
write it to a file (which should be configured as binary as for reading).
Michael
This what I did by use binary format
set fp [open ./add.dat w]
set outBin [binary format Ia5xxxa80xxx 1 cmd passwd]
fconfigure $fp -translation binary
puts -nonewline $fp $outBin
close $fp
what I get in add.dat is :
^@^@^@^Acmd^@^@^@^@^@command^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@
but for chkr2k3.dat which create by C it show:
^A^@^@^@cmd^@:command^@^D~B^D^H^D~B^D^H
~G^D^H^T~^^D^H@~]^D^Hl๘ฟฟ๖ท^DH^D^@^@^@^@r^EH๔๗ฟฟ�~G^D^H^T~^^D^H@~]^D^Hl๘ฟฟ^@r^EH^ZN^MH^P~L^D^H^X๘ฟฟต~D^D^H^A^@^@^@
The purpose of my program is I would like to get the value from
interface to write in binary file by Tcl programming and then read
that binary file use C programming so I try to see how write binay file
in the same format in C struct which I use
However, Thank you so much for all of your suggestion
.
- Follow-Ups:
- Re: write binary file with struct in tcl
- From: Uwe Klein
- Re: write binary file with struct in tcl
- From: Paul Whitfield
- Re: write binary file with struct in tcl
- References:
- write binary file with struct in tcl
- From: add
- Re: write binary file with struct in tcl
- From: Michael Schlenker
- Re: write binary file with struct in tcl
- From: add
- Re: write binary file with struct in tcl
- From: Krys
- Re: write binary file with struct in tcl
- From: Michael Schlenker
- Re: write binary file with struct in tcl
- From: add
- Re: write binary file with struct in tcl
- From: Michael Schlenker
- write binary file with struct in tcl
- Prev by Date: Re: Thoughts about the controversial {expand} feature
- Next by Date: problem installing aolserver 4.5.0 on redhat ENT 3 linux from source
- Previous by thread: Re: write binary file with struct in tcl
- Next by thread: Re: write binary file with struct in tcl
- Index(es):
Relevant Pages
|
|