Error in tcl script

hi all ,

i am trying to link a file with another file present in some other location in tcl shell. This is the way i am doing it

if {[file exists "/data/athena_dev/tanvi/tcl/tanvi.log"]} {
file link /data/athena_dev/tanvi/tcl/tanvi.log "/data/athena_dev/tanvi/tanvi.tcl"
}

I am getting the error that /data/athena_dev/tanvi/tcl/ta nvi.log -- this path already exists.

What is t=wrong i am doing here, please point me to that .

Thanks
Tanvi

Hi.

It looks like your arguments are in the wrong order:

#!/usr/bin/env tclsh

# @(#) s2     Demonstrate "file link".

puts stdout ""
set version [ info tclversion ]
set message " Hello, world from tclsh ($version)"
puts stdout $message

puts stdout ""
if { $argc == 0 } then {
  puts stdout " No command line parameters provided."
  set file "stdin"
} else {
  set i 0
  puts stdout " Command line arguments:"
  foreach arg $argv {
    set m1 " $i $arg"
    incr i
    set m2 ""
    if { [ file exists $arg ] } then {
      set m2 [ join [ list "(" [ file type $arg ] ")" ] ]
    }
    puts stdout "$m1 $m2"
	set file $arg
  }
}

puts ""
exec rm -f a b
exec touch a
exec ls -lgG a >@stdout

puts ""
puts " Results for link b a"
file link b a
exec ls -lgG a b >@stdout

puts ""
exec rm -f a b
exec touch a
puts " Results for link a b"
file link a b
exec ls -lgG a b >@stdout

exit 0

producing:

% ./s2

 Hello, world from tclsh (8.4)

 No command line parameters provided.

-rw-r--r-- 1 0 May 23 14:12 a

 Results for link b a
-rw-r--r-- 1  0 May 23 14:12 a
lrwxrwxrwx 1 37 May 23 14:12 b -> .../a

 Results for link a b
could not create new link "a": that path already exists
    while executing
"file link a b"
    (file "./s2" line 43)

Found by experimentation.

Best wishes ... cheers,drl