COMPGROUPS.NET | Browse | Post | Groups | Users | Stream | 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

9 Replies
253 Views

Similar Articles

[PageSpeed] 31

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

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

Can code in a script file start running before file loaded?
If you've got some inline code in a JS file at the top of the file, is that allowed to start running (and by that I mean will the browser start executing it) before the entire JS file has loaded? Is that possible? I don't want it to be possible, I want to be sure that it won't happen. Joe Nine wrote: > If you've got some inline code in a JS file at the top of the file, is > that allowed to start running (and by that I mean will the browser start > executing it) before the entire JS file has loaded? Is that possible? Inline code in a JS file? If you mean...

Why can execution results in tcl shell differ than if using tcl script??
Hi, I have been posting a thread here: http://groups.google.com/group/comp.lang.tcl/browse_thread/thread/983d7ef3e4b1ab54# I have another question that might be related to it, I'm doing set of tcl commands (involving external shell commands execution) one time in tcl shell, and the other from a tcl script.. Although both command sequences are the same, I get quite different results!!! Why did this happens?? Thanks, Ahmad Ahmad wrote: > Hi, > > I have been posting a thread here: > http://groups.google.com/group/comp.lang.tcl/browse_thread/thread/983d7ef3e4b1ab54# > >...

How can I use the content of a text file, which is the argument of the script, inside the script?
Hi all I have a piece of text file called "part1" as below: ----------------------------------------------------- // Kanal 1 L P#272.0 T "IDB_AICB64".Channel[1].PEWAdr L 0 T "IDB_AICB64".Channel[1].DataType ----------------------------------------------------- I have written a script to generate a multiple of this text part with different consecutive numbers like below: Output: ----------------------------------------------------- // Kanal 1 L P#272.0 T "IDB_AICB64".Channel[1].PEWAdr L ...

upload ".zip" file [transfer files using tcl script]
I want to upload .zip file from my windows box to unix box i mean i want to transfer files using tcl script. Thanks in advance file transfer protocol - ftp - is the protocol of choice. A wiki page "Simple ftp uploader" shows an example using the ftp package. May I suggest to access the wiki page per http://taipu.de/ida.htm, to get pointed to the wiki page http://wiki.tcl.tk/1502 with minimal typing effort? best regards, Roland Frank senthilvaishnavi schrieb: > I want to upload .zip file from my windows box to unix box i mean i > want to transfer files using...

Can I compile a tcl/tk extended C file into an exe file on windows?
I'm new to tcl/tk. I have a simple tk/tcl extended C file like this, #include <stdio.h> #include <stdlib.h> #include <tcl.h> #include <tk.h> int Tcl_AppInit(Tcl_Interp* interp) { int status; status = Tcl_Init(interp); if (status != TCL_OK) { return TCL_ERROR; } /* Initialize Tk values. */ status = Tk_Init(interp); if (status != TCL_OK) { return TCL_ERROR; } return TCL_OK; } int main(int argc, char** argv) { Tk_Main(argc, argv, Tcl_AppInit); return 0; } Can I compile this file into an exe file on windows? How? Thank you ysrise@gmail.com (yan) writes: [snip[ ...