I have a tcl script that generate a lot of intermediate files (and
folders). At the last step of my script, I've to clean the working
directory and keep only one or two files.
I have written a proc to clean work dir like this:
proc cleanWorkDir {dir keep1 {keep2 ""}} {
set here [pwd]
cd $dir
if {$keep2 == "" } {
set keep2 $keep1
}
foreach f [glob -nocomplain *] {
if { ![string equal $f [getOnlyName $keep1] ] && ![string equal
$f [getOnlyName $keep2]] } {
file delete -force $f
}
}
cd $here
}
Although it worked on my laptop, but on customer's Linux machine I
always get error message:
ERROR: cannot remove `A/B/.nfs00000000010d28ba00004dfb': Device or
resource busy
while executing
"file delete -force $f"
...
Despite of being able to delete the whole folder (Folder "A" in error
message) manually, I don't understand why cannot the TCL script do it!
Can anyone help me solve this?
Thanks,
Ahmad
What is the .nsf file stands for? Who generates it?
Thanks,
Ahmad
>
> I have also noticed something.. When the TCL script exits after this
> error, and I try to "ls" the ".nsf...." file it complains about, I
> don't find it!
>
> What is the .nsf file stands for? Who generates it?
NFS -- 'Network File System', a UNIX file sharing protocol, originally
invented by Sun Microsystems back in the late 1970's or so. The
".nsf...." file is something created by the NFS software, I think
related to locking.
>
> Thanks,
> Ahmad
>
>
> On Nov 4, 12:45=A0pm, Ahmad <ahmad.abdulgh...@gmail.com> wrote:
> > Hi,
> >
> > I have a tcl script that generate a lot of intermediate files (and
> > folders). At the last step of my script, I've to clean the working
> > directory and keep only one or two files.
> >
> > I have written a proc to clean work dir like this:
> >
> > proc cleanWorkDir {dir keep1 {keep2 ""}} {
> > =A0 =A0set here [pwd]
> > =A0 =A0cd $dir
> > =A0 =A0if {$keep2 =3D=3D "" } {
> > =A0 =A0 =A0set keep2 $keep1
> > =A0 =A0}
> >
> > =A0 =A0foreach f [glob -nocomplain *] {
> > =A0 =A0 =A0if { ![string equal $f [getOnlyName $keep1] ] && ![string equa=
> l
> > $f [getOnlyName $keep2]] } {
> > =A0 =A0 =A0 =A0 file delete -force $f
> > =A0 =A0 =A0}
> > =A0 =A0}
> > =A0 =A0cd $here
> >
> > }
> >
> > Although it worked on my laptop, but on customer's Linux machine I
> > always get error message:
> > ERROR: cannot remove `A/B/.nfs00000000010d28ba00004dfb': Device or
> > resource busy
> > =A0 =A0 while executing
> > =A0 "file delete -force $f"
> > ...
> >
> > Despite of being able to delete the whole folder (Folder "A" in error
> > message) manually, I don't understand why cannot the TCL script do it!
> >
> > Can anyone help me solve this?
> >
> > Thanks,
> > Ahmad
>
>
--
Robert Heller -- 978-544-6933 / hel...@deepsoft.com
Deepwoods Software -- http://www.deepsoft.com/
() ascii ribbon campaign -- against html e-mail
/\ www.asciiribbon.org -- against proprietary attachments
This is a very nice to know, thank you.
Do you have any idea how can I force delete this kind of files?
Thanks,
Ahmad
On Nov 4, 1:26 pm, Robert Heller <hel...@deepsoft.com> wrote:
> Deepwoods Software --http://www.deepsoft.com/
>
> Hi Robert,
>
> This is a very nice to know, thank you.
>
> Do you have any idea how can I force delete this kind of files?
I don't think you can OR should.
>
> Thanks,
> Ahmad
>
>
> On Nov 4, 1:26=A0pm, Robert Heller <hel...@deepsoft.com> wrote:
> > At Thu, 4 Nov 2010 12:54:20 -0700 (PDT) Ahmad <ahmad.abdulgh...@gmail.com=
> > wrote:
> >
> >
> >
> > > I have also noticed something.. When the TCL script exits after this
> > > error, and I try to "ls" the ".nsf...." file it complains about, I
> > > don't find it!
> >
> > > What is the .nsf file stands for? Who generates it?
> >
> > NFS -- 'Network File System', a UNIX file sharing protocol, originally
> > invented by Sun Microsystems back in the late 1970's or so. The
> > ".nsf...." file is something created by the NFS software, I think
> > related to locking.
> >
> >
> >
> >
> >
> > > Thanks,
> > > Ahmad
> >
> > > On Nov 4, 12:45=3DA0pm, Ahmad <ahmad.abdulgh...@gmail.com> wrote:
> > > > Hi,
> >
> > > > I have a tcl script that generate a lot of intermediate files (and
> > > > folders). At the last step of my script, I've to clean the working
> > > > directory and keep only one or two files.
> >
> > > > I have written a proc to clean work dir like this:
> >
> > > > proc cleanWorkDir {dir keep1 {keep2 ""}} {
> > > > =3DA0 =3DA0set here [pwd]
> > > > =3DA0 =3DA0cd $dir
> > > > =3DA0 =3DA0if {$keep2 =3D3D=3D3D "" } {
> > > > =3DA0 =3DA0 =3DA0set keep2 $keep1
> > > > =3DA0 =3DA0}
> >
> > > > =3DA0 =3DA0foreach f [glob -nocomplain *] {
> > > > =3DA0 =3DA0 =3DA0if { ![string equal $f [getOnlyName $keep1] ] && ![s=
> tring equa=3D
> > > l
> > > > $f [getOnlyName $keep2]] } {
> > > > =3DA0 =3DA0 =3DA0 =3DA0 file delete -force $f
> > > > =3DA0 =3DA0 =3DA0}
> > > > =3DA0 =3DA0}
> > > > =3DA0 =3DA0cd $here
> >
> > > > }
> >
> > > > Although it worked on my laptop, but on customer's Linux machine I
> > > > always get error message:
> > > > ERROR: cannot remove `A/B/.nfs00000000010d28ba00004dfb': Device or
> > > > resource busy
> > > > =3DA0 =3DA0 while executing
> > > > =3DA0 "file delete -force $f"
> > > > ...
> >
> > > > Despite of being able to delete the whole folder (Folder "A" in error
> > > > message) manually, I don't understand why cannot the TCL script do it=
> !
> >
> > > > Can anyone help me solve this?
> >
> > > > Thanks,
> > > > Ahmad
> >
> > --
> > Robert Heller =A0 =A0 =A0 =A0 =A0 =A0 -- 978-544-6933 / hel...@deepsoft.c=
> om
> > Deepwoods Software =A0 =A0 =A0 =A0--http://www.deepsoft.com/
> > () =A0ascii ribbon campaign -- against html e-mail
> > /\ =A0www.asciiribbon.org=A0 -- against proprietary attachments
>
>
--
Robert Heller -- 978-544-6933 / hel...@deepsoft.com
Deepwoods Software -- http://www.deepsoft.com/
Simon
I agree with Robert that the lock files can't be deleted. The first
question you should have is why are they being created. Is there some
good reason that the files you have created are being locked by a
remote host? If not then I would spend some time figuring what the
heck is going on. Second, the /tmp directory on unix/linux is where
you should be putting all your temporary files. This directory is
cleared when a system is rebooted which will remove any abandoned lock
files. In a large network it is possible for lock files to become
abandoned which is a real headacke because they will prevent
directories from being deleted.
tomk
To see the file you should propbaly try
ls -al
This lists all files including hidden ones, under Linux the . before a
filename will hide them from simple ls
You should probably be creating a private tmp directory in /tmp to
keep all your files together then a simple delete of the directory
should clean up easily.
Martyn
Those .nfs files are not related to file locking, but to removed files
on an NFS share which are still open in some application.
See
https://www.cs.indiana.edu/Facilities/FAQ/General/dotnfs.html
http://www.unix.com/filesystems-disks-memory/5702-removing-nfs-files.html
HTH
R'
may be one more tip is you can use exception handling if script is
actually aborting without completion where you can use tcl catch
statement for file delete operation and print messages when some cases
it fails as busy etc.