0
votes

I am new in tcl.

I want to ask the question about tcl exec command. I want to execute the command through exec with -file arguments. for example

exec myprogram -tcl -file [file_name.tcl] -nogui

I am writing this code in tcl_file and trying to execute the tcl code through tclsh tcl_file.tcl , but due to wrong arguments I could not able to pass file_name. advance thanks

1
my tcl_file contain only this command [exec myprogram -tcl -file "file_name.tcl" .] - ARK91
What was the exact error message? - Donal Fellows
invalid command name "file_name.tcl" while executing "file_name.tcl" invoked from within "exec myprogram -tcl -file [file_name.tcl] -nogui " (file "tcl_file" line 3) - ARK91

1 Answers

0
votes

The problem you've got is that [ and ] are used in Tcl to surround commands for substituting. It's making the filename be interpreted as a (really quite unusual) Tcl command name.

You're probably OK doing just this:

exec myprogram -tcl -file file_name.tcl -nogui

Without the []. However, if the program that you're calling needs the square brackets, you'll have to backslash-quote them:

exec myprogram -tcl -file \[file_name.tcl\] -nogui

That's pretty unlikely. Prefer the first option.