Hi all, I have a ksh script that calls a tcl proc that sets a variable that I am attempting to return to the calling script? Is this possible or does the tcl variable live in its own space that I cannot access from ksh.
I have tried the following but when I do the var in my script is empty although the tclproc processes correctly:
varname=`tclproc call blah blah`
I have a statement at the end of the tclproc that states return $var
I don't know tcl, but instead of return, you must write the value to stdout for the backtick construct to pick it up. Try echo or print, something like that.
I had actually already considered writing the variable from tcl to a file that I could then access when I returned to my script. I guess I am more interested in seeing whether the return value can be accessed once execution is returned to the script.
To a file?
varname=`tclproc call blah blah`
will work fine. See those quotes you used? They are backticks. They pick up what the enclosed command outputs.
Then you didn't write anything to stdout. Try this command:
date
See how the date and time appears on your screen? That is because the date command wrote some characters to stdout. Now try this:
x=`date`
echo x = $x
Now x has been set to the date and time. Now you need to work on your script until you can do:
tclproc call blah blah
and see some output on your screen. Then you are ready to use the backticks to pick it up.