简体   繁体   中英

How to Interface TCL and Shell scripts to C/C++ or any other languages?

I have few scripts developed in TCL and Shell

  1. TCL scripts (project.tcl) is used for automation of project creation and handling the multiple project runs)
  2. SHELL scripts (result.sh ) is created for result analysis Error handling with a set of commands using sed, awk and grep.

I want to create a single executable by embedding these scripts into any high level language like C/C++ file. we know that TCL is a C library. What kind of interface files APIs are useful for achieving this?

  1. TCL scripts are quite simple, as you can embed the TCL interpreter quite easy. (API-Reference: https://wiki.tcl-lang.org/page/Tcl+C+API )
  2. You can simply embed them, extract them at runtime (to /tmp) and use system(...) , or you could try translating them to C: sed: https://github.com/lhoursquentin/sed-bin awk: awk2c grep: I didn't find some translator tool, but grep uses PCRE , so you could use these.

To have them in the executable, you could make a.tar(.gz) file from those scripts, embed it into the binary ( Embedding binary blobs using gcc mingw ), and load (and extract (with zlib, for example)) it at runtime, to a temporary directory.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM