<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
James Aylett wrote:
<blockquote cite="mid20041005090331.GA11999@tartarus.org" type="cite"><br>
<pre wrap="">
That wasn't what I meant - I've had ln -sf fail to unlink the previous
symlink. And silently fail. This is one of the reasons why I don't
like using symlinks :-/
</pre>
<blockquote type="cite">
<pre wrap="">We're getting away from the original issue here. I doubt Sam is
accessing his databases over NFS, and I'd be stunned if he was accessing
them over NFS to a Windows server.
</pre>
</blockquote>
<pre wrap=""><!---->
I meant more "I've had this problem (amongst others) with symlinks,
which is why I'm wary of them", meaning that if you're right about
rename() (and it would be weird if it didn't work), people should just
use the things, and at some point I'll get over my phobia ...
</pre>
</blockquote>
<br>
Here's my report and some sample bash:<br>
<br>
export DBDIR=$HOME/xapian<br>
export DBLINK=$HOME/xapian/data<br>
<br>
readlink() {<br>
link="`stat -t -c '%N' \"$1\" 2>/dev/null`" || return<br>
link="`echo \"$link\" | grep -- '->' 2>/dev/null `" || return<br>
link="`echo \"$link\" | sed -e 's/^.*-> .\(.*\).$/\1/'
2>/dev/null`" || return<br>
echo "$link"<br>
}<br>
<br>
serial=`date '+%s'`<br>
newdb=$DBLINK.$serial<br>
olddb="`readlink $DBLINK`" && echo fine $olddb || echo no $olddb<br>
<br>
dbi2omega blah | \<br>
scriptindex --overwrite $newdb cetoptics.si /dev/fd/0 && \<br>
ln -s $newdb $newdb.lnk && perl -e "rename '$newdb.lnk',
'$DBLINK';" && rm -fr "$olddb"<br>
<br>
I had to use perl's rename because "mv" moved the new link inside the
target directory of the old link (when it existed) instead of replacing
the old link. The rename command also became confused.<br>
<br>
To be honest so much hacky stuff is going on here with readlink and all
I should probably do it all in perl<br>
<br>
Sam<br>
<br>
<br>
<br>
<br>
</body>
</html>