why I cannot delete the file second time

Forum for OpenSees users to post questions, comments, etc. on the use of the OpenSees interpreter, OpenSees.exe

Moderators: silvia, selimgunay, Moderators

Post Reply
kengawk
Posts: 103
Joined: Wed Oct 31, 2007 11:55 pm
Location: Beijing JIaotong University
Contact:

why I cannot delete the file second time

Post by kengawk »

Dear,

At first run, the following code can delete the temp_grp.txt.
When I run it second time, it shows:error deleting "./temp_grp.txt": permission denied. :?: :?:

the following is codes.


wipe
set val1 [clock seconds];
set file_ID "Param_test1.txt"
set comments "#"
set file [open [format "%s" $file_ID] "r"]

set count_grp 0
while {-1 != [gets $file line] } {
if { [string first "#" $line] != 0 } {


set count_grp [expr $count_grp + 1]
# wrong # args: should be "set varName ?newValue?" <---set count_grp 1 [expr $count_grp + 1]


if [catch {open ./temp_grp.txt r} field] {

#puts "field: $field"
puts stderr "no file finded,create!!"

set field [open ./temp_grp.txt w]

puts $field $count_grp
close $field
unset field
puts "record group count1: $count_grp"

} else {


set grp_seq [read $field]
if {$count_grp < $grp_seq} {


puts "count_grp < grp_seq"
close $field
unset field
continue

} else {

set field [open ./temp_grp.txt w]
puts $field $count_grp
close $field
unset field
}
# end of that if $count1 < $grp_seq

}
#########
}
}

#-----------------------------------------
#########
puts "del temp_grp.txt!!"
file delete "./temp_grp.txt"
#########
#-----------------------------------------

set val2 [clock seconds]
set elapsedTime [expr $val2-$val1]
set days [expr int($elapsedTime/86400)]
set hours [expr int(($elapsedTime-$days*86400)/3600)]
set minutes [expr int(($elapsedTime- $days*86400-$hours*3600)/60)]
set seconds [expr int($elapsedTime- $days*86400-$hours*3600-$minutes*60)]
puts "COMPLETED :"
puts "Total Time Required --> $days days $hours hours $minutes minutes $seconds seconds"
wipe
[\code]
Kai Zhang
------------------------------
PH.D. candidate
School of Civil Engineering&Architecture
Beijing Jiaotong University
fmk
Site Admin
Posts: 5884
Joined: Fri Jun 11, 2004 2:33 pm
Location: UC Berkeley
Contact:

Re: why I cannot delete the file second time

Post by fmk »

what operating system are you using?
kengawk
Posts: 103
Joined: Wed Oct 31, 2007 11:55 pm
Location: Beijing JIaotong University
Contact:

Re: why I cannot delete the file second time

Post by kengawk »

thank you, Frank!

Xp and win7, Both of them is 64 bit system.
Sometimes, the error that cannot delete the temp_recovery file would stop the batch process.

Cheers
Ken
Kai Zhang
------------------------------
PH.D. candidate
School of Civil Engineering&Architecture
Beijing Jiaotong University
Post Reply