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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using exec tclsh "$0" "$@"

Status
Not open for further replies.

marknel

Technical User
Apr 8, 2002
6
US
ofcourse, I'm new to TCL and programming as a whole.

over the last few weeks I've been teaching myself TCL with a fair amount of success. Right now, however, I can't seem to get the 'exec tclsh "$0" "$@"' to work.

It's not a major issue for me, but I'm trying to understand it.

Code example:

#!/bin/sh
exec tclsh "$0" "$@"
set dir [file dirname [info script]]
puts $dir
set pwd [exec pwd]
puts $pwd

***********
what I get when I try to run (./dirtest.tcl) is:

can't read "0": no such variable
while executing
"exec tclsh "$0" "$@""
(file "./dirtest.tcl" line 2)

what am I doing wrong?

Thanks in advance!!!

Marknel
 
You missed the mandatory second line of the script!
You need to have:
Code:
#!/bin/sh
#exec tclsh "$0" "$@"
at the beginning of your script.
Adding "#\" makes the magic.

For an explanation, see:
ulis
 
ahh sometimes its the simple things..

thank you!!!

Marknel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top