1 Reply Latest reply on Mar 19, 2013 8:11 AM by jarviswabi

    CFTTP Remove action doesn't actually delete file

    jarviswabi Level 1

      I'm about to throw my monitor through the wall on this one.  I'm working on a process to retrieve order files from an sFTP server, and I have to delete them off the server after downloading them.  The CFFTP action="remove" call is returning a success status code, but the file is not actually being deleted from the server.  I've tested this under both FTP and sFTP (the server supports both), and it's the same both ways.  I also tested deleting the file through an FTP client (SecureFX), and that way it DOES actually delete the file, so I'm inclined to think it's not the server somehow blocking the action.


      Here's my code:


      <cfset ftpfolder="/Outbox/orders">

      <cfftp connection="ftpconn" server="#ftpserver#" username="#ftpuser#" password="#ftppw#" action="open" secure="true">

      <cfftp connection="ftpconn" action="changedir" directory="#ftpfolder#">

      <cfftp connection="ftpconn" action="listdir" directory="#ftpfolder#" name="orders">

      <cfdump var="#orders#">

      <cfloop query="orders">

                <cfif Right(path,4) EQ ".asc">

                          <cfftp connection="ftpconn" action="getfile" remotefile="#path#" localfile="#inputdir##name#" failifexists="no">

                          <cfftp connection="ftpconn" action="getcurrentdir">

                          <cfftp connection="ftpconn" action="remove" item="#cfftp.returnvalue##name#">

                          <cfdump var="#cfftp#">



      <cfftp connection="ftpconn" action="listdir" directory="#ftpfolder#" name="noworders">

      <cfdump var="#noworders#">

      <cfftp connection="ftpconn" action="close">


      The dumps of #orders# and #noworders# show me the directory listing before and after the delete, and they're constantly identical.  The dump of the cfftp after the remove consistently shows me this:


      ErrorTextSSH_FX_OK successful completion of the operation
      ReturnValue0 SSH_FX_OK successful completion of the operation


      But the damn file is still there.  I had originally NOT had the getcurrentdir call in there, just specifying the directory statically in the remove statement, but it was the same result.

      I read the cfftp.succeeded as meaning that I'm specifying a valid file name, but for some reason it's not going away.  I tried this under CF8 and CF10 to the same results.


      Anybody seen this behavior before?  I guess another option would be to try spawning a separate process to delete the files, but that really sucks.