Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

executing tcl-file with arguments

Status
Not open for further replies.

Thodd

Technical User
Oct 21, 2006
27
BE
Hi,

I'm trying to execute a tcl-file by passing some arguments from another tcl-file.

#main.tcl
for {set i 1} {$i <= 3} {incr i} {
exec {./ns.exe} test.tcl($i)
}

#test.tcl
set ns [new Simulator]
...
set name "file"
append name $i
append name ".tr"
set fileId [open $filename "w"]
...

How can I pass that variable i to test.tcl?
thx!
 
I'm trying to run main.tcl, which runs another tcl-file (called test.tcl). But test.tcl has to generate some files with different filenames, hence that parameter $i.
But I don't know how to do it, I tried with exec {./ns.exe} test.tcl($i) but it doesn't work...
Probably it will be something with $arg0 or so.
 
Hi

Works for me like this :
Code:
[blue]master #[/blue] cat first.tcl            
#!/usr/bin/tclsh
set answer [exec {second.tcl} {ho ho ho} {Hello World !}]
puts "The runned program answered this :"
puts $answer

[blue]master #[/blue] cat second.tcl 
#!/usr/bin/tclsh
puts "When I, $argv0, was started, got $argc info :"
for {set i 0} {$i<$argc} {incr i} {
  puts " - [lindex $argv $i]"
}

[blue]master #[/blue] first.tcl
The runned program answered this :
When I, ./second.tcl, was started, got 2 info :
 - ho ho ho
 - Hello World !

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top