I'm working on a file explorer inTCL/Tk and I want to add a little thing to execute commands with the current selection (using %l %f) %l executing with the full list and %f executing the commmand with each file. my only problem is that if I type a command like "gedit" for eg it works but as soon as I type a command with argument it doesn't work ... I've been looking everywhere and I don't get it... If someone could help me... btw getl var Name is a function that returns me a FileName in full path (/home/...) and if I return the string that is supposed to be executed and put it in a terminal it works...
Here is the code:
proc tl_exec {liste command } {
#lorsqu'il faut effectué la commande avec la liste en param
if { [string first "%l" $command] > 0} {
foreach v $liste {
lappend args [getl $v Name]
}
set com [string map [list "%l" [join $args " "] ] $command ]
puts $com
set val [exec [split $com " "] ]
} elseif { [string first "%f" $command] > 0} {
#lorsqu'il faut effectué la commande pour chaque fichier
foreach v $liste {
set com [string map list ["%f" [getl $v "Name"] ] $command ]
lappend val [ exec [split $com " "] ]
}
} else {
#lorsqu'on a pas de fichiers
set val [exec $command]
}
}
Thanks a lot