On Friday, February 11, 2022 at 10:35:00 AM UTC-8, snosniv wrote:
I have a simple batch file which invokes Java to run a conversion algorithm, this works just fine, but I can't seem to get it work within Tcl.
batch file is:
cd c:/Users/Downloads/Fit_files
java -jar C:\Users\Downloads\__Installation_files\FitSDKRelease_21.67.00\java\FitCSVTool.jar -b C:\Users\Downloads\Fit_files\FIT2CSV\INFILE.fit C:\Users\Downloads\Fit_files\FIT2CSV\OUTFILE.csv
But I can't seem to invoke Java from within Tcl?
What do I need to do please?
You have to take care with file path names in Tcl. The syntax for a pathname is different from a cmd shell. The backslash character (\) is used as an escape character, so in Tcl, to use it in a path name, the character must be escaped:
java -jar c:\\Users\\Downloads\\__Installation_files\\FitSDKRelease_21.67.00\\java\\FitCSVTool.jar -b C:\\Users\\Downloads\\Fit_files\\FIT2CSV\\INFILE.fit C:\\Users\\Downloads\\Fit_files\FIT2CSV\OUTFILE.csv
Or you can essentially escape the entire path using braces ({}):
java -jar {C:\Users\Downloads\__Installation_files\FitSDKRelease_21.67.00\java\FitCSVTool.jar} -b {C:\Users\Downloads\Fit_files\FIT2CSV\INFILE.fit} {C:\Users\Downloads\Fit_files\FIT2CSV\OUTFILE.csv}
Or you can use forward slashes (/):
java -jar C:/Users/Downloads/__Installation_files/FitSDKRelease_21.67.00/java/FitCSVTool.jar -b C:/Users/Downloads/Fit_files/FIT2CSV/INFILE.fit C:/Users/Downloads/Fit_files/FIT2CSV/OUTFILE.csv
Of course in order to run any external program, the [exec] command should be used:
exec java -jar ...
To capture any return values, use the [set] command:
set return_value [exec java -jar ...]
Also, you can verify that Tcl can find the program using the [autoexec_ok] command:
if {[autoexec_ok java] ne ""} {
set return_value [exec java -jar ...]
}
-Brian
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)