Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Tcl way to create a symlink

2 views
Skip to first unread message

Todd M. Helfter

unread,
May 9, 2002, 11:23:31 AM5/9/02
to

Is there a combinition of [file ] arguements that will let me create a unix
sym link?

I know that tclX has a [link ] command to do this, but I am trying to reduce
dependencies.

Thanks
Todd
--
Todd M. Helfter
Database Analyst/Programmer
Purdue University
t...@purdue.edu

McGarva, Ian

unread,
May 9, 2002, 2:00:51 PM5/9/02
to
"Todd M. Helfter" wrote:

> Is there a combinition of [file ] arguements that will let me create a unix
> sym link?

Is there a reason why you would not want to use unix's "ln" command?

e.g. exec ln -s realFile.db myNewLink

Ian McUsingthetintcl

Donal K. Fellows

unread,
May 10, 2002, 9:51:44 AM5/10/02
to
"Todd M. Helfter" wrote:
> Is there a combinition of [file ] arguements that will let me create a unix
> sym link?

No. (There *should* be and it should work cross-platform whereever the general
concept is supported, but there isn't.) TIPs to alter this would be gladly
accepted.

Donal.
--
Donal K. Fellows http://www.cs.man.ac.uk/~fellowsd/ fell...@cs.man.ac.uk
-- "I'm going to open a new xterm. This one's pissing me off" Anon. (overheard)

Jeffrey Hobbs

unread,
May 10, 2002, 11:15:36 AM5/10/02
to
"Donal K. Fellows" wrote:
>
> "Todd M. Helfter" wrote:
> > Is there a combinition of [file ] arguements that will let me create a unix
> > sym link?
>
> No. (There *should* be and it should work cross-platform whereever the general
> concept is supported, but there isn't.) TIPs to alter this would be gladly
> accepted.

The problem is the only platform that supports the idea of Unix symlinks
is ... unix, which is why TclX has the support and it hasn't made it
into Tcl. Windows has shortcuts, but that is really a Desktop notion
and isn't comprehended at the DOS level.

--
Jeff Hobbs The Tcl Guy
Senior Developer http://www.ActiveState.com/
Tcl Support and Productivity Solutions

Darren New

unread,
May 10, 2002, 1:00:38 PM5/10/02
to
Jeffrey Hobbs wrote:
> The problem is the only platform that supports the idea of Unix symlinks
> is ... unix,

Actually, Windows has sym links also. They're called "reparse points",
and they're a lot more powerful than just symbolic links. They allow for
sym links, hard links, mounted file systems, files stored on tape that
automatically prompt the operator to restore them when you try to open
them, etc.

> Windows has shortcuts, but that is really a Desktop notion
> and isn't comprehended at the DOS level.

That's because a Windows shortcut is a shell alias, not a file system
concept. :-)

--
Darren New
San Diego, CA, USA (PST). Cryptokeys on demand.
The 90/10 rule of toothpaste: the last 10% of
the tube lasts as long as the first 90%.

Dwaine Gonyier

unread,
May 10, 2002, 1:16:18 PM5/10/02
to
Just FYI you might find this interesting reading:

http://www.sysinternals.com/ntw2k/source/misc.shtml#junction

--
Dwaine Gonyier
OTBU Software Engineer / Cisco Systems, Inc. / RTP NC US
dgon...@cisco.com
* My opinions are my own, not my employer's, blah blah blah...

"Jeffrey Hobbs" <Je...@ActiveState.com> wrote in message news:3CDBE549...@ActiveState.com...

Jeff Hobbs

unread,
May 10, 2002, 1:46:22 PM5/10/02
to
> > The problem is the only platform that supports the idea of Unix symlinks
> > is ... unix, which is why TclX has the support and it hasn't made it
> > into Tcl. Windows has shortcuts, but that is really a Desktop notion
> > and isn't comprehended at the DOS level.

Dwaine Gonyier wrote:
> Just FYI you might find this interesting reading:
> http://www.sysinternals.com/ntw2k/source/misc.shtml#junction

Darren New wrote:
> Actually, Windows has sym links also. They're called "reparse points",
> and they're a lot more powerful than just symbolic links. They allow for
> sym links, hard links, mounted file systems, files stored on tape that
> automatically prompt the operator to restore them when you try to open
> them, etc.

From the page that Dwaine mentions:

Win2K's version of NTFS supports directory symbolic links, where a
directory serves as a symbolic link to another directory on the
computer. For example, if the directory D:\SYMLINK specified
C:\WINNT\SYSTEM32 as its target, then an application accessing
D:\SYMLINK\DRIVERS would in reality be accessing
C:\WINNT\SYSTEM32\DRIVERS. Directory symbolic links are known as
NTFS junctions in Win2K. Unfortunately, Win2K comes with no tools
for creating junctions - you have to purchase the Win2K Resource Kit,
which comes the linkd program for creating junctions. I therefore
decided to write my own junction-creating tool: Junction. Junction
not only allows you to create NTFS junctions, it allows you to see if
files or directories are actually reparse points. Reparse points are
the mechanism on which NTFS junctions are based, and they are used by
Win2K's Remote Storage Service (RSS), as well as volume mount points.

So we are talking about something only available in NT/2K/XP, and only
on NTFS file systems. This is not what I would like to have to explain
in the docs in the caveats about why it doesn't work for most people ...

Besides, it only mentioned directories in the first case, which is not
sufficient. What users would expect is something that works like unix
symlinks - you open a file that is a symlink, you actually get the end
point of the link chain. You exec it, again it follows. Directories
and files should be treated the same.

If someone thinks they have a clever way to abstract this concept and
make it work across platforms, I would welcome the solution.

As an alternative, I have been working on TclX 8.4 to make it a much
easier extension to use. I would also like to start expanding it to
include more platform specific functionality, in namespaces (like a
win32:: set of functions).

--
Jeff Hobbs The Tcl Guy
Senior Developer http://www.ActiveState.com/
Tcl Support and Productivity Solutions

Join us in Sept. for Tcl'2002: http://www.tcl.tk/community/tcl2002/

Darren New

unread,
May 10, 2002, 2:15:52 PM5/10/02
to
Jeff Hobbs wrote:
> So we are talking about something only available in NT/2K/XP, and only
> on NTFS file systems.

True. But it's also incorrect to say that only Unix supports sym links.

> Besides, it only mentioned directories in the first case, which is not
> sufficient.

That may be all that's built in. You would have to add a reparse point
handler to deal with individual files in the particular way you want to
deal with them. But it's a general mechanism
there that works for directories, files, etc. Basically, it's kind of
like setuid - more powerful than ACLs, but you also have to write the
program that deals with it. NTInternals just didn't do that. :-)

I wasn't really addressing the applicability to Tcl, but rather simply
correcting the statement that only UNIX supports symlinks.

Kevin Kenny

unread,
May 10, 2002, 5:28:22 PM5/10/02
to
You know, given that it would work on NT/2k/XP (assuming NTFS) and on Unix
(and presumably MacOS8), I'd support adding [file symlink] and implementing
a version of [file readlink] for NTFS. One caveat is that I don't know whether
junction points actually work. Do they?

// Kevin

--
73 de ke9tv/2, Kevin KENNY GE Corporate R&D, Niskayuna, New York, USA

Donal K. Fellows

unread,
May 13, 2002, 3:47:44 AM5/13/02
to
Kevin Kenny wrote:
> You know, given that it would work on NT/2k/XP (assuming NTFS) and on Unix
> (and presumably MacOS8), I'd support adding [file symlink] and implementing
> a version of [file readlink] for NTFS. One caveat is that I don't know whether
> junction points actually work. Do they?

I'd prefer [file link $filename ?$targetFilename?]. Omit the target to read the
link, and present the target to set the link. Easy, and follows the convention
used in many other places...

-- If somebody in a suit or a uniform can sit you down and have you believe
every word he says, you've just surrendered your license to be a thinking
human being and traded it in for a zombie suit. -- mh...@prince.carleton.ca

McGarva, Ian

unread,
May 13, 2002, 11:26:36 AM5/13/02
to
"Donal K. Fellows" wrote:
>
> Kevin Kenny wrote:
> > You know, given that it would work on NT/2k/XP (assuming NTFS) and on Unix
> > (and presumably MacOS8), I'd support adding [file symlink] and implementing
> > a version of [file readlink] for NTFS. One caveat is that I don't know whether
> > junction points actually work. Do they?
>
> I'd prefer [file link $filename ?$targetFilename?]. Omit the target to read the
> link, and present the target to set the link. Easy, and follows the convention
> used in many other places...

My $.02 worth:

I think that a few things can be said about symbolic links:

1 - not every platform supports them;
2 - every platform that does support them has its own quirks; and,
3 - there is no third thing.

I vote for leaving out symbolic link support. Anyone that feels inclined
to use them still has the option, via exec (assuming there is support
for that in Windoze), *and* they can choose all their own, OS-specific
options themselves.

Fire away!

Ian McKISS

Darren New

unread,
May 13, 2002, 11:44:29 AM5/13/02
to
"McGarva, Ian" wrote:
> 1 - not every platform supports them;
> 2 - every platform that does support them has its own quirks; and,
> 3 - there is no third thing.

I think the third thing is that hard links are at least as useful.

--
Darren New
San Diego, CA, USA (PST). Cryptokeys on demand.

** http://home.san.rr.com/dnew/DNResume.html **

Roger Oberholtzer

unread,
May 21, 2002, 8:28:50 AM5/21/02
to
Darren New wrote:
> "McGarva, Ian" wrote:
>
>>1 - not every platform supports them;
>>2 - every platform that does support them has its own quirks; and,
>>3 - there is no third thing.
>
>
> I think the third thing is that hard links are at least as useful.

Provided you don't want to cross file systems.

vince darley

unread,
May 21, 2002, 1:59:21 PM5/21/02
to
"Donal K. Fellows" <fell...@cs.man.ac.uk> wrote in message news:<3CDF6FA0...@cs.man.ac.uk>...

> Kevin Kenny wrote:
> > You know, given that it would work on NT/2k/XP (assuming NTFS) and on Unix
> > (and presumably MacOS8), I'd support adding [file symlink] and implementing
> > a version of [file readlink] for NTFS. One caveat is that I don't know whether
> > junction points actually work. Do they?
>
> I'd prefer [file link $filename ?$targetFilename?]. Omit the target to read the
> link, and present the target to set the link. Easy, and follows the convention
> used in many other places...

I like Donal's suggestion. My only caveat is whether it would be
useful to have other options ('-hard'?). MacOS supports symlinks as
well, so assuming we can get support for MacOS, Unix and WinNT/2000
we're covering most of the bases.

I considered building support for this into the fs-overhaul, but
didn't in the end (because I don't know how it works on all these
platforms). However, there is actually part of the infrastructure for
it present in Tcl -- 'Tcl_FSLink' (and therefore TclpObjLink in
mac/win/unix dirs) is the C-level equivalent of Donal's 'file link
$name ?$target?'. So, all that is needed is an implementation of
those and an addition to Tcl_FileObjCmd. Everything in between
(including vfs support) is already there!

Vince.

vince darley

unread,
Jun 6, 2002, 6:05:50 AM6/6/02
to
Jeff Hobbs <Je...@ActiveState.com> wrote in message news:<3CDC076E...@ActiveState.com>...

> Besides, it only mentioned directories in the first case, which is not
> sufficient. What users would expect is something that works like unix
> symlinks - you open a file that is a symlink, you actually get the end
> point of the link chain. You exec it, again it follows. Directories
> and files should be treated the same.
>
> If someone thinks they have a clever way to abstract this concept and
> make it work across platforms, I would welcome the solution.

See: http://www.hlm.inc.ru/ for making file-links. I think one could
reasonably abstract this across all platforms, at least in the common
90% of cases (a quick google search of comp.lang.tcl for 'file link'
shows dozens of matches for requests stretching back several years!).

cheers,

Vince.

vince darley

unread,
Jun 7, 2002, 6:09:42 PM6/7/02
to
Kevin Kenny <ken...@acm.org> wrote in message news:<3CDC3B76...@acm.org>...

> You know, given that it would work on NT/2k/XP (assuming NTFS) and on Unix
> (and presumably MacOS8), I'd support adding [file symlink] and implementing
> a version of [file readlink] for NTFS. One caveat is that I don't know whether
> junction points actually work. Do they?

I have a version of 'file link $from $to' which works under Win2000
now... So it does work!

Vince.

Darren New

unread,
Jun 7, 2002, 6:20:43 PM6/7/02
to
vince darley wrote:
> I have a version of 'file link $from $to' which works under Win2000
> now... So it does work!

Cool! Does it work for regular files too? Or just directories?

--
Darren New
San Diego, CA, USA (PST). Cryptokeys on demand.

** http://home.san.rr.com/dnew/DNResume.html **
** http://images.fbrtech.com/dnew/ **

My brain needs a "back" button so I can
remember where I left my coffee mug.

vince darley

unread,
Jun 10, 2002, 6:50:25 AM6/10/02
to
Darren New <dn...@san.rr.com> wrote in message news:<3D0131D4...@san.rr.com>...

> vince wrote:
> > I have a version of 'file link $from $to' which works under Win2000
> > now... So it does work!
>
> Cool! Does it work for regular files too? Or just directories?

Just directories at the moment, but the source is there, so you can
try to add file support too.

http://sourceforge.net/tracker/index.php?func=detail&aid=562970&group_id=10894&atid=310894

lvi...@yahoo.com

unread,
Jun 11, 2002, 8:28:42 AM6/11/02
to

According to vince darley <vincen...@users.sourceforge.net>:
:Kevin Kenny <ken...@acm.org> wrote in message

Vince, why file link rather than file symlink ?
--
Support Internet Radio <URL: http://saveinternetradio.org/ >
Join Tcl'2002 in Vancouver http://www.tcl.tk/community/tcl2002/
Even if explicitly stated to the contrary, nothing in this posting
should be construed as representing my employer's opinions.

Jeffrey Hobbs

unread,
Jun 11, 2002, 12:34:47 PM6/11/02
to
lvi...@yahoo.com wrote:
> :I have a version of 'file link $from $to' which works under Win2000
> :now... So it does work!
>
> Vince, why file link rather than file symlink ?

Well, they are two options. ln and ln -s, so perhaps file link would
have a -symbolic (or soft link) option. Again, this would just make
things harder to do cross-platform.

lvi...@yahoo.com

unread,
Jun 12, 2002, 12:04:48 PM6/12/02
to

According to Jeffrey Hobbs <Je...@ActiveState.com>:

:lvi...@yahoo.com wrote:
:> :I have a version of 'file link $from $to' which works under Win2000
:> :now... So it does work!
:>
:> Vince, why file link rather than file symlink ?
:
:Well, they are two options. ln and ln -s, so perhaps file link would
:have a -symbolic (or soft link) option. Again, this would just make
:things harder to do cross-platform.

Perhaps, but it seems like the wrong approach to use a vague name for
this. Why not say file symlink and file link so that people using it
know what they are getting?

0 new messages