View Full Version : [iTCL] 'file size ..' returns 0 on POST STOR/RETR ?
bizniz
02-28-2004, 03:15 PM
for some reason when running itcl script on POST STOR/RETR,
set s [file size $path]
returns '0'
but on getting the size of another existing file elsewhere that hasnt just been STOR/RETR returns the size properly ? :/
What is the value of $path ?
darkone
02-28-2004, 09:37 PM
it _always_ points to directory. You need to combine arguments with path to get filename.
bizniz
02-28-2004, 10:04 PM
i know, i know .. ok, ill call the var $mypath,
$mypath IS set to a valid filename,
ie.
$mypath == "C:/this/file.r01" :)
try yourself, you'll see :D
Mouton
02-28-2004, 11:18 PM
You're doing something wrong in your code. file size works just fine here, even in post STOR event.
Test using ioisotopehelper custom command:
[FTP_Custom_Commands]
ioIsotopeHelper = TCL ..\scripts\ioIsotope.itcl
[23:14:32] [L] site ioisotopehelper cidx
[23:14:32] [L] 200-CIDX;3;Mouton;Admins;*;127.0.0.1;pomme2k3;download ;RETR test1.rar;/race/test/;/race/test/test1.rar;2004-02-28 23:14:12;20;18;5.0;196608;15000000;
[23:14:32] [L] 200 Command successful.Last number is file size in bytes... See code below.
Test using post stor event:
[FTP_Post-Command_Events]
stor = TCL ..\scripts\ioIsotope.itcl cidx
[23:14:40] [L] Opening data connection IP: 127.0.0.1 PORT: 1034
[23:14:40] [L] STOR SomeHeader.h
[23:14:40] [L] 150 Opening ASCII mode data connection for SomeHeader.h.
[23:14:40] [L] CIDX;3;Mouton;Admins;*;127.0.0.1;pomme2k3;download ;RETR test1.rar;/race/test/;/race/test/test1.rar;2004-02-28 23:14:12;28;26;5.0;196608;15000000;
[23:14:43] [L] 226 Transfer complete.
[23:14:43] Transferred: SomeHeader.h 6 KB in 2.22 (2.72 KBps)Worked too... file size = 15000000 bytes...
itcl code used:
switch $status {
0 { set status "idle" }
1 { set status "download" ; set filesize [file size [resolve pwd [lindex $data 8]]]}
2 { set status "upload" ; set filesize [file size [resolve pwd [lindex $data 8]]]}
3 { set status "list" }
}
iputs "CIDX;[lindex $data 0];[resolve uid [lindex $data 1]];[resolve gid $gid];[lindex $data 2];[lindex $data 3];[lindex $data 4];$status;[lindex $data 6];[lindex $data 7];[lindex $data 8];$logintime;$logindiff;[lindex $data 10];[lindex $data 11];[lindex $data 12];$filesize;"
Ofloo
05-06-2004, 04:07 PM
not entirely sur what u want i suppose the file size of ur dir ..
foreach x [glob -nocomplain -type f -dir $path *] {
if {[info exists i]} {
set i [expr [file size $x]+$i]
} else {
set i [file size $x]
}
}
return $i
for main dir rerun it for every dir .. to do it restructive ..
darkone
05-06-2004, 11:37 PM
It's propably smarter to set i to 0, before entering that loop to remove one extra if ;)
vBulletin® v3.8.11 Alpha 3, Copyright ©2000-2024, vBulletin Solutions, Inc.