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

What is a "busy file? How can i delete in TCL script?

292 views
Skip to first unread message

Ahmad

unread,
Nov 4, 2010, 3:45:44 PM11/4/10
to
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 ""}} {
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

Ahmad

unread,
Nov 4, 2010, 3:54:20 PM11/4/10
to
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?

Thanks,
Ahmad

Robert Heller

unread,
Nov 4, 2010, 4:26:19 PM11/4/10
to
At Thu, 4 Nov 2010 12:54:20 -0700 (PDT) Ahmad <ahmad.ab...@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=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



Ahmad

unread,
Nov 4, 2010, 6:16:08 PM11/4/10
to
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?

Thanks,
Ahmad


On Nov 4, 1:26 pm, Robert Heller <hel...@deepsoft.com> wrote:

> Deepwoods Software        --http://www.deepsoft.com/

Robert Heller

unread,
Nov 4, 2010, 7:56:45 PM11/4/10
to
At Thu, 4 Nov 2010 15:16:08 -0700 (PDT) Ahmad <ahmad.ab...@gmail.com> wrote:

>
> 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

unread,
Nov 5, 2010, 6:14:08 AM11/5/10
to
Your script is trying to delete all files in a directory except those
you specify. It would probably be better to maintain a list of the
temporary files and just loop through the list at the end deleting them,
that way you avoid trying to delete other files (like the NFS lock files).

Simon

tomk

unread,
Nov 5, 2010, 12:10:28 PM11/5/10
to
On Nov 4, 4:56 pm, Robert Heller <hel...@deepsoft.com> wrote:

> At Thu, 4 Nov 2010 15:16:08 -0700 (PDT) Ahmad <ahmad.abdulgh...@gmail.com> wrote:
>
>
>
> > 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.
>
>

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

MSEdit

unread,
Nov 5, 2010, 1:51:22 PM11/5/10
to

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

Ralf Fassel

unread,
Nov 5, 2010, 2:59:48 PM11/5/10
to
* Robert Heller <hel...@deepsoft.com>

| > What is the .nsf file stands for? Who generates it?
>
| ... The ".nsf...." file is something created by the NFS software, I
| think related to locking.

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'

SANKY

unread,
Nov 11, 2010, 8:13:30 AM11/11/10
to
@Ahmad

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.

0 new messages