Is there any TCL package to untar .tar.bz2 files?
I tried TCL tar library but I could not able to achieve it.
Thanks in advance.
This isn't trivial. You'll need something to decompress the tar.bz2 file — I've found some source code at http://download.gna.org/bztcl/0.6/ but I can't verify that it will work easily for you on Windows — and you can then use the tar library that you've already found. The bztcl build apparently needs tclmore too — see http://download.gna.org/tclmore/0.7/ — and you'll need to have a C compiler available, and probably a build of the bzip2 library too.
Due to the complex nature of the bzip2 compression format, I don't think there's ever been anyone who's written a pure Tcl decompressor for it.
Related
I am having a very large JSON file, but it's poorly formatted so that all the chars are in one line only, no \n anywhere, which makes it difficult to read and understand. And since it's more than one kilobyte file, editing it manually is out of the question.
I am looking for a command or some other way to format a JSON file quickly, for human readability, and save it into the same file or another one. Ideally I shouldn't have to setup too many things. I know that some IDEs include automatic formatting features, however installing another IDE onto my work computer is not an option for me.
The JSON is in a file? You could do this:
python -m json.tool my_json.json
Built into python from version 2.5? 2.6? And it will pretty-ify the json for you.
I am using a commercial tool interfaced with an homebrew tclsh(Synopsys EDA).
In their version, they removed the load command. Thus I cannot use third party libraries (Graphviz library in my case).
I wonder if there is a another way to import binary files (.so files)
The only command in standard Tcl that brings in a dynamic library is load. (OK, package require can do too, but that's because it can call load inside.) Without that command, you only have options like statically linking your own code in and creating the commands in the Tcl_AppInit function, but that's really unlikely to work if you're already using someone else's code that's already done that sort of thing.
The easiest approach might be to run a normal tclsh as a subprocess via exec tclsh script.tcl (run and wait for termination) or open |tclsh r+ (open pipeline). If they've not turned off those capabilities as well; you might be running in a safe interpreter where all those things are systematically disabled. I don't know of any way to break out of a standard safe interpreter (the mechanism for locking them down errs on the side of caution) so if that's the case, you'll just have to save the data you want to a file somewhere (by any mechanism that works; safe interpreters also can't touch the filesystem at all by default though that is often profiled back in in protected ways) and use a completely separate program to work with it.
What's the difference between the Perl JSON modules below?
I have come across JSON::PP and JSON::XS. The documentation of JSON::PP says it is compatible with JSON::XS. What does that mean?
I am not sure what the difference between them are, let alone which of them to use. Can someone clarify?
Perl modules sometimes have different implementations. The ::PP suffix is for the Pure Perl implementation (i.e. for portability), the ::XS suffix is for the C-based implementation (i.e. for speed), and JSON is just the top-level module itself (i.e. the one you actually use).
As noted by #Quentin, this site has a good description of them. To quote:
JSON
JSON.pm is a wrapper around JSON::PP and JSON::XS - it also does a bunch of moderately crazy things for compatibility reasons, including extra shim code for very old perls [...]
JSON::PP
This is the standard pure perl implementation, and if you're not performance dependent, there's nothing wrong with using it directly [...]
JSON::XS
Ridiculously fast JSON implementation in C. Absolutely wonderful [...]
As you can see, just installing the top-level JSON module should do it for you. The part about compatibility just means that they both do the same thing, i.e. you should get the same output from both.
I installed the Perl JSON module a few years ago on a RHEL server I managed and it was a really straightforward process: just install (or build) the module from the CPAN site and you're done.
Installing should be a simple case of either using the OS package manager (if in GNU/Linux), using the cpan utility, or building from source. The OS package manager is recommended, as it helps keep things updated automatically.
To verify that it's installed, just try the following command from the terminal (assuming GNU/Linux):
$ perl -e 'use JSON;'
If it doesn't complain, then you should be good to go. If you get errors, then you should get ready to go in an adventure.
You can install JSON module, cpan install JSON
use JSON;
my $result = from_json($json);
if($result->{field})
{
# YOUR CODE
};
Is there a script to upload a *.pof file using TCL Scripting through Quartus Programmer on my FPGA?
Preferably from the command line because i want integrate it into my custom software.
If you just want a command-line utility you can run quartus_pgm like this:
quartus_pgm -z --mode=JTAG --operation="p;/path/to/image.sof#2"
where #2 indicates the device in the JTAG chain to program. You might also be interested in quartus_jli which writes JAM files.
For full details look at the Quartus II Scripting Reference Manual. I'm not sure whether you can use the JTAG package directly from TCL though, the documentation suggests only from a shell in SignalTap (see table 3).
Can anyone explain me what is the use of init.tcl?
When actually it is loaded by the TCL interpreter?
The description for this file is shown as
startup file for TCL .
But According to my knowledge .tclshrc is the start up file.
Can anyone explain this?
Actually, init.tcl is the first file that is loaded by a Tcl_Interp*.
Its job is to setup the different package loading mechanisms.
Some programs, most notably tclsh, will source the .tclshrc. This is usually done using Tcl_SourceRCFile.
So init.tcl is sourced for every Tcl interpreter, while the .tclshrc is only sourced by some programs that explicitly do that.
* does not apply to safe interpreters