Go Back   FlashFXP Forums > >

Programming Need help with C/C++/Delphi? Ask here and make us all laugh.

Closed Thread
 
Thread Tools Rate Thread Display Modes
Old 05-06-2004, 03:23 PM   #1
Ofloo
Member
 
Join Date: Jun 2003
Posts: 43
Default [TCL] Renaming a file on PRE STOR

i got this under pre

PHP Code:
[FTP_Pre-Command_Events]

stor TCL ..\scripts\ioSfv\ioSfv.tcl sfvstore 
i want to rename from filename.incomplete to filename

for some reason this doesn't seem to be working anyone any ideas ??

i think its the pre thing .. cause

PHP Code:
--------------------------- ErrorInfo ----------------------------
error renaming "..\site\test\15[.mp3.incomplete" to "..\site\test\15[.mp3"file already exists
    
while executing
"file rename -- $path\\[lindex $arg end].incomplete $path\\[lindex $arg end]"
    
(procedure "sfvstore" line 6)
    
invoked from within
"sfvstore "$args""
    
invoked from within
"if {[info exists args]} {
  if {[string match -nocase sfvcheck [lindex 
$args 0]]} { 
Ofloo is offline  
Old 05-06-2004, 04:00 PM   #2
neoxed
Too much time...
FlashFXP Beta Tester
ioFTPD Scripter
 
Join Date: May 2003
Posts: 1,326
Default

Try posting related portions of your code, or are we supposed to read your mind?
neoxed is offline  
Old 05-06-2004, 04:08 PM   #3
tuff
Senior Member
FlashFXP Registered User
ioFTPD Scripter
 
Join Date: Jan 2003
Posts: 277
Default

"file rename -- $path\[lindex $arg end].incomplete $path\[lindex $arg end]"

im almost sure if you place a \ before a [ in tcl, tcl will interpet the [ as part of the string and NOT as a command

since your using the same command twice there, why not simply

set what [lindex $arg end] ?
__________________
#iotools #ioftpd (both on efnet)
tuff is offline  
Old 05-06-2004, 04:12 PM   #4
Ofloo
Member
 
Join Date: Jun 2003
Posts: 43
Default

as in reading my mind isn't that hard pre stor and file rename ..

well i wana rename a file as i suggested from filename.incomplete to filename


now as in \[ i knwo about this i think the forum removes it .. just found out if u put [php] arround it it strips crap

Quote:
proc sfvstore {arg} {
global path
set arg [string map {\\ \\\\ \[ \\\[ \] \\\] \{ \\\{ \} \\\} \( \\\( \) \\\)} $arg]
set path [string map {\\ \\\\ \[ \\\[ \] \\\] \{ \\\{ \} \\\} \( \\\( \) \\\)} $path]
if {[file exists $path\\[lindex $arg end].incomplete]} {
file rename -- $path\\[lindex $arg end].incomplete $path\\[lindex $arg end]
iputs -nobuffer "$path\\[lindex $arg end].incomplete $path\\[lindex $arg end]"
}
}

Ofloo is offline  
Old 05-06-2004, 04:25 PM   #5
Ofloo
Member
 
Join Date: Jun 2003
Posts: 43
Default

Quote:
226 ABOR command successful.
User Aborted
PASV
227 Entering Passive Mode (192,168,0,100,7,149)
REST 1310720
350 Restarting at 1310720. Send STORE or RETRIEVE to initiate transfer.
STOR 15.mp3
Renameing ..\site\test\15.mp3.incomplete to ..\site\test\15.mp3
150 Opening BINARY mode data connection for 15.mp3.
i tryed with and without mapping string or regsub if u prefer i prefer string map its faster and does same thing
Ofloo is offline  
Old 05-06-2004, 04:26 PM   #6
Ofloo
Member
 
Join Date: Jun 2003
Posts: 43
Default

altho it could be post .. let me check that ..
Ofloo is offline  
Old 05-06-2004, 04:28 PM   #7
Ofloo
Member
 
Join Date: Jun 2003
Posts: 43
Default

no thats not it it must be something else tho cause the resume is set before stor so what would u suggest i use sinds post isn't triggerd ..
Ofloo is offline  
Old 05-06-2004, 04:45 PM   #8
Ofloo
Member
 
Join Date: Jun 2003
Posts: 43
Default

no it is stor just before stor i have to do

iputs -nobuffer REST [file size $path\\[lindex $arg end].incomplete]
then rename it but for some reason tis isn't working ...
Ofloo is offline  
Old 05-06-2004, 05:13 PM   #9
neoxed
Too much time...
FlashFXP Beta Tester
ioFTPD Scripter
 
Join Date: May 2003
Posts: 1,326
Default

Quote:
Originally posted by Ofloo
as in reading my mind isn't that hard pre stor and file rename ..
No, If you read my original statement I was referring to your code not your idea.

Quote:
Originally posted by Ofloo
i tryed with and without mapping string or regsub if u prefer i prefer string map its faster and does same thing
Well if you read the TCL documentation, regsub and string map have very different uses. Regsub is used for regular expression substitutions and string map simply replaces one or several characters in a given string.

In your sample code, you should be using "lrange $arg 1 end" rather then "lindex $arg end". If someone uploaded a file that contained a space, your script would fail.

PHP Code:
if {[file exists $path\\[lindex $arg end].incomplete]} {
    
file rename -- $path\\[lindex $arg end].incomplete $path\\[lindex $arg end]
    
iputs -nobuffer "$path\\[lindex $arg end].incomplete $path\\[lindex $arg end]"

On "pre stor" events, the file doesn't exist yet. So the [file exists ...] is meaningless. Thus why your file is not being renamed. Try using "post stor" if wasn't so lazy at the moment, I would try myself.
neoxed is offline  
Old 05-06-2004, 05:20 PM   #10
Ofloo
Member
 
Join Date: Jun 2003
Posts: 43
Default

file exists has meaning tho i check if file incomplete exists to rename it cause if its not there it will return an error also normal i check for the other file but sinds it is no use cause the pre doesn't work well left it out ..

if u check the error u would know cause it cant be renamed it is saying can't rename cause file allready exists witch means it is renameing it

i could check if the target file exists or use -force but sinds the file is openend for writing, .. wouldn't do mutch good .. so .. no point realy i could check if the traget file is there in order to prevent an error but still my problem remains all it would do is not return an error

also pre does exist cause it is triggerd if it would not exist then it wouldn't trigger that it is not pre that i know cause it is executed after the event also i tryed lrange and if u wana use lrange u should also add join other wize it has no effect cause then u get { } on spaces witch is not the idea .. sinds i wana make it work first then worry about the spaces i used lindex .. sinds there are no spaces in my current path.

[join [lrange $arg 2 end]]

other wize it will only add {}

i know about string map and regsub but there is nothing u can change by replacing {} to [] and the code will be executed then just mapped .. also all i need to do is replace so ..
Ofloo is offline  
Old 05-06-2004, 05:32 PM   #11
neoxed
Too much time...
FlashFXP Beta Tester
ioFTPD Scripter
 
Join Date: May 2003
Posts: 1,326
Default

I still don't see the point in renaming the file on "pre stor"...it would be much more logical to rename the file on the OnUploadComplete event.
neoxed is offline  
Old 05-06-2004, 06:40 PM   #12
Ofloo
Member
 
Join Date: Jun 2003
Posts: 43
Default

The whole point is when a file is incomplete not when it is complete that crap i got sorted its once u wana resume

look i don't want incomplete files to be renamed to .bad

also u don't need lrange sinds the arguments in ioftpd have "" arround them thats basicly the same as

{argument argument}

if u do lindex 0 on that u will get argument argument as result ..

as i sad basicly it comes down to the same thing this means i am not saying it is !!

one of the mestakes in easySFV he splits it on "
Ofloo is offline  
Old 05-06-2004, 11:36 PM   #13
darkone
Disabled
FlashFXP Registered User
ioFTPD Administrator
 
darkone's Avatar
 
Join Date: Dec 2001
Posts: 2,230
Default

How about renaming it on [post] stor ;? that would tell you, wheter file create actually succeeded. (only problem you will encounter, that after failed upload - you must take care of file yourself.. io will try to delete file with invalid name, which propably makes any other script go crazy)
darkone is offline  
Old 05-07-2004, 11:45 AM   #14
Ofloo
Member
 
Join Date: Jun 2003
Posts: 43
Default

hmm ic
Ofloo is offline  
Closed Thread

Tags
$arg, $args, file, pre, sfvstore

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 11:51 PM.

Parts of this site powered by vBulletin Mods & Addons from DragonByte Technologies Ltd. (Details)