My TCL script puts together a call to a command line tool using TCL variables. I've tried exec or eval for the command line but nothing worked.
#!/usr/bin/tclsh
set dbg 0
set iso 100
set cmd "gphoto2 --set-config-value /main/imgsettings/iso=${iso}"
if {$dbg} {puts $cmd} else {eval $cmd}
Gives :
invalid command name "gphoto2"
while executing
"gphoto2 --set-config-value /main/imgsettings/iso=100"
("eval" body line 1)
invoked from within
"eval $cmd"
invoked from within
"if {$dbg} {puts $cmd} else {eval $cmd}"
(file "./canon.tcl" line 22)
If tried { exec $cmd } but that did not work either.
couldn't execute "gphoto2 --set-config-value /main/imgsettings/iso=100": no such file or directory
while executing
"exec $cmd"
invoked from within
"if {$dbg} {puts $cmd} else {exec $cmd}"
(file "./mofi_canon.tcl" line 22)
I tried giving absolute path name /usr/bin/gphoto2 but again no success.
I guess the problem has to do with the entire command string being one object and the unix execution cannot parse it. But what's the way to give it to the shell properly?
from the linux command line of course the command works fine.
@ubuntu:~/TCL$ gphoto2 --summary
Camera summary:
Manufacturer: Canon Inc.
Model: Canon EOS DIGITAL REBEL XSi
This is from a kubuntu 14.04 linux.
uname -a
Linux ubuntu 3.13.0-36-generic #63-Ubuntu SMP Wed Sep 3 21:30:07 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
Thanks & Cheers, Gert
which gphoto2.$cmdstring into an array of separate strings, one per argument, and then useexec. The error message indicates it couldn't find a single command calledghphoto2 --set-config-value …. You could use"sh"and"-c"and the current value of$cmdtoo:else { exec "sh" "-c" $cmd }or thereabouts — my Tcl/Tk is rusty at best.