COMPGROUPS.NET | Post | Groups | Users | Stream | Browse | About | |

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

• Email
• Follow

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,

 0

See related articles to this posting

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,

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


 0

At Thu, 4 Nov 2010 12:54:20 -0700 (PDT) Ahmad <ahmad.abdulghany@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,
>
>
> > 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,
>
>

--
Robert Heller             -- 978-544-6933 / heller@deepsoft.com
Deepwoods Software        -- http://www.deepsoft.com/
()  ascii ribbon campaign -- against html e-mail
/\  www.asciiribbon.org   -- against proprietary attachments


 0

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,

On Nov 4, 1:26=A0pm, Robert Heller <hel...@deepsoft.com> wrote:
> 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,
>
> > > 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,
>
> --
> 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


 0

At Thu, 4 Nov 2010 15:16:08 -0700 (PDT) Ahmad <ahmad.abdulghany@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,
>
>
> 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,
> >
> > > > 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,
> >
> > --
> > 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 / heller@deepsoft.com
Deepwoods Software        -- http://www.deepsoft.com/
()  ascii ribbon campaign -- against html e-mail
/\  www.asciiribbon.org   -- against proprietary attachments


 0

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

On 04/11/2010 23:56, Robert Heller 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,
>>
>>
>> On Nov 4, 1:26=A0pm, Robert Heller<hel...@deepsoft.com>  wrote:
>>> 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,
>>>
>>>>> 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,
>>>
>>> --
>>> 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
>>
>>
>


 0

On Nov 4, 4:56=A0pm, Robert Heller <hel...@deepsoft.com> wrote:
> 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

 0

On 5 nov, 17:10, tomk <krehbiel....@gmail.com> wrote:
> On Nov 4, 4:56=A0pm, Robert Heller <hel...@deepsoft.com> wrote:
>
> > At Thu, 4 Nov 2010 15:16:08 -0700 (PDT) Ahmad <ahmad.abdulgh...@gmail.c=
om> 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

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

 0

* Robert Heller <heller@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'

 0

@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
 comp.lang.tcl 21601 articles. 10 followers.

9 Replies
270 Views

Similar Articles

[PageSpeed] 16

• Email
• Follow

Similar Artilces:

What is a "busy file? How can i delete in TCL script?
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 } ... Tcl script hangs on deleting directory from remote machine while works for files Hi All, As a part of my tcl script, my requirement is i need to delete contents (i.e. files and directories with my login id) from remote machine. So i am using following code catch {exec /usr/bin/rsh$mac_n {\rm -r ls -lrt /local/test | grep $username | awk {{ print$NF}}}} err1 Now this code deletes files successfully and instantaneously but it hangs while deleting folders. I also tried an alternative solution for deleting files of my login using csh script, but again while executing same script from tcl it hangs. Can some one please help me in figuring out the problem with this code. ...

how do you have tclsh source files such that I can run say rglob script, since rglob not part of tcl
until I source ti rglob not here so how write script usinf rglob there must be a switch to tclsh to source a file b4 running ret of script? I am sure this is easy but dont know how On 7/6/2012 3:24 PM, quiet_lad wrote: > until I source ti rglob not here > > so how write script usinf rglob > > there must be a switch to tclsh to source a file b4 running ret of > script? > > I am sure this is easy but dont know how > What's rglob in this context? Based on your question, I assume it's a command defined by a Tcl procedure that's in a...

cannot delete file
cannot delete file - http://LongPathTool.com can fix it Do you have error messages?, like : Path too long. Error cannot delete file: cannot read from source file or disk Cannot delete file: Access is denied There has been a sharing violation. Cannot delete file or folder The file name you specified is not valid or too long. Specify a different file name. The source or destination file may be in use. The file is in use by another program or user. Error Deleting File or Folder Make sure the disk is not full or write-protected and that the file is not currently in use. Error Copy...

cannot delete file
cannot delete file - http://LongPathTool.com can fix it Do you have error messages?, like : Path too long. Error cannot delete file: cannot read from source file or disk Cannot delete file: Access is denied There has been a sharing violation. Cannot delete file or folder The file name you specified is not valid or too long. Specify a different file name. The source or destination file may be in use. The file is in use by another program or user. Error Deleting File or Folder Make sure the disk is not full or write-protected and that the file is not currently in use. Error Copy...

Cannot Delete File? Long Path Tool Can - http://CannotDeleteFile.net LONG PATH Tool
Cannot Delete File? Long Path Tool Can - http://CannotDeleteFile.net LONG PATH Tool - Windows tool to copy or delete files and folders with path too long error Windows tool to copy or delete files and folders with path too long or filename too long error. Just browse to the file and press a button to copy or detele it, thats it! The application solves the problem with inability to copy and delete files and folders with long paths in Explorer. They could be created by virus/adware/Mac OS/other software. Normally one can't access such files under Windows and therefore can't ...

can a deleted bat file delete an exe that deleted it?
Have an exe that needs to delete itself and other files in the same folder but this cannot be done. So thought I would use a bat file. Problem is that the exe is not deleted if the exe deletes the bat file and its folder first. I thought I could: 1 start the exe via a bat file that lives in the same folder. 2 The exe deletes all files including the bat file and folder they all live in 3 The exe ends and the running - but deleted - bat file then deletes the exe. 4 Plan is no files are left but exe is left in the folder above - see bat below I thought I could get this working...

http://HowToDeleteFile.com - Cannot Delete File? Long Path Tool Can These are some of the other error messages that you could encounter while using Windows: Cannot delete file
http://HowToDeleteFile.com - Cannot Delete File? Long Path Tool Can These are some of the other error messages that you could encounter while using Windows: Cannot delete file - Access denied The destination or source file might be in use There is been a sharing violation The file is being used by another user or program Cannot delete folder or file. The file name specified is too long or not valid. Error Deleting folder or file There is no doubt that you have come across other error messages because these are just a few of them. But, you should know that whenever you try to mo...

GUI *.fig file deleted, *.m file still exists, can *.fig file be retrieved?
I created a GUI, but the *.fig file was deleted, the *.m or code file still exists, can *.fig file be retrieved or can I regenerate the *.fig file from the *.m file? I am using MATLAB 6.5 Release 13. Please Help! Brian Bird wrote: > > > I created a GUI, but the *.fig file was deleted, the *.m or code > file > still exists, can *.fig file be retrieved or can I regenerate the > *.fig file from the *.m file? I am using MATLAB 6.5 Release 13. > Please Help! No, however the file might still be on the hard disk. Google for "undelete". One of the first hits is <h...

Dose there any tcl script to translate an file with embedded tcl
Hi I need to generate some big file, but there are rules for generate these files Ex . ============================== Start input a [0] wire input a [1] wire .. .. .. .. input a [1000] wire End ================================= Dose there any tcl script can help to translate a file with embedded tcl script into a new file For example this is a source file ======================== Start * set i 0 * for { set i 0 } { $i < 1000 } { incr i } { * puts input a [$i] wire * } End ========================== After Translate ======================= Start input a [0] wire input a [1] wire .. .. ...