SaiVamshi Dobbali
SaiVamshi Dobbali

Reputation: 89

invoke a tcl script from another tcl script with multiple arguements

i am invoking script(tclscript) from the current script seeing this "invalid command name error" the tcl script just checks the proper version of package is installed or not.

#!/bin/tclsh
# i am doing this for multiple packages in a loop
set list {/usr/local/script}
lappend list -check
lappend list -package
lappend list tcl-devel
lappend list version

[eval exec $list]

output:

invalid command name "
checking the version [ ok ] #expected output
-checks successful!         #expected output
"
    while executing
"[eval exec $list]"

dont understand why i get this "invalid command name error"can anyone help

Upvotes: 0

Views: 217

Answers (1)

Donal Fellows
Donal Fellows

Reputation: 137587

The problem is that you've successfully run the command, have got the results back, and are then trying to use those results as the name of a command because you put [brackets] around the eval exec. Either remove the brackets, or put a command name before them so that you use the result as an argument.

set list …
# Leaving out the details of how you build the list

eval exec $list
set list …
# Leaving out the details of how you build the list

set result [eval exec $list]
puts "result is \"$result\""

Upvotes: 0

Related Questions