View Single Post
Old 10-20-2011, 07:11 PM  
Yil
Too much time...
 
Join Date: May 2005
Posts: 1,194
Default

At first I suppose this looks like an error, but it really isn't...

Your test looks a simple 'site' command (as opposed to pre/post events which are different) and all FTP commands must end in a valid 3 digit response code so the client knows if things succeeded or not. Without any script output the server uses the exit() code of the application and prints out a 200/500 code to signal success/failure.

However, you DID output the word "test" and relied upon ioFTPD to prefix it with a "200-". 200 is the default for site commands indicating success and the "-" means this isn't the final line with the only value that actually matters. After the script ran ioFTPD looked at the buffer, saw the last line was a "ddd-" continuation line and inferred the script result from that. Hence a "200 ..."success line was added so the FTP client would be happy.

For success you don't need to do anything since it will add the generic "200 Command successful." line, but you can use your own "200 Whatever" line at the end if you want a custom success message like "200 Successfully marked item" or whatever. UPDATE: You'll need to !prefix off" to actually enter such a line into the buffer.

For failure the only thing you have to do is make sure the last line ends in a "5xx Whatever" format so use "!prefix off" then output that line. If you output lines before that one you'll get the default prefix (i.e. 200- for site commands) added. If you want all the output to look like errors you'll have to use the "!prefix off" command at the start and then output your own prefixed lines like "550-Couldn't find 'foo'.".

I've been tempted to offer a way to have the server modify all lines to make the prefix numbers match the final output or to make a way to change the prefix before outputting lines, but it's not possible now so you'll have to do it yourself.

Specific response codes are defined in the FTP RFC's but you probably won't care about them as 200/550 works for nearly everything a site script cares about. The default prefix code used by ioFTPD for each type of event/script/etc can be found in /doc/Events.txt. You'll see that it's based upon the most likely response for the type of event. The ioPrefix variable in iTCL contains the default prefix for lines, but EXEC modules don't get that info but you can infer it from Events.txt and what triggered the script.

Last edited by Yil; 10-20-2011 at 07:27 PM.
Yil is offline   Reply With Quote