Is it possible to call a function in tcl script which is aactually defined in anothe shell script? For example,
my shell script function is
add ()
{
`a=$1
b=$2
c=`expr $a + $b`
`}
How to call this function inside a tcl file? please guide me with this
It isn’t really possible to call a function written in another language from Tcl except in a few ways. For example, a C function can be called if it conforms to Tcl’s command definition signature, or if some glue code is present (such as might be generated with SWIG or Critcl). The other way to call the code is by invoking it in another process, typically a subprocess. Running the command in a shell script might then be done like this (assuming your function definition is in
my_script.sh):But that’s rather clunky and inclined to cause problems when dealing with more complicated input values. I advise turning your script into a whole program that can run more directly (so you can do
exec my_script.sh 123 456) or, better yet, writing it in some other language which has fewer mysterious gotchas than Unix shell (i.e., most languages!)