0 Replies Latest reply on May 21, 2010 6:36 AM by jmac70

    CF8 - org.apache.commons.net.ftp.FTPClient library errors

    jmac70

      I need to ftp a file to a remote unix server from our ColdFusion server (on windows), after the file transfer I need to chmod the file

       

      I am able to transfer the file without a problem, but I get an error when trying to use any of the java methods in the

      org.apache.commons.net.ftp.FTPClient

       

      library, which I believe I need to use the method sendSiteCommand method to change the file permissions

       

      I am running a cfdump of the myConnection variable imediately after I create the java object, and I see all of the java methods, so I assume this is the correct library to use;  I also do a cfdump of the myConnection variable after the cfftp open and it looks like I loose the java object there.

       

      I have only found one exampl on how to do this on the we and it was for CF 6, using the coldfusion.oroinc.net.ftp.FTPClient

      library, but this is not available in CF8.

       

      since I "loose" the java object, no matter which method in that library I use I get the following error:

       

      "Diagnostics:The sendSiteCommand method was not found. Either there are no methods with the specified method name and argument types, or the sendSiteCommand method is overloaded with argument types that ColdFusion cannot decipher reliably. ColdFusion found 0 methods that matched the provided arguments. If this is a Java object and you verified that the method exists, you may need to use the javacast function to reduce ambiguity. "

       

      code:

      <cfoutput>

       

      <cffile action="write" file="#localCsvFile#" output="#strOutput#">

       

       

       

      <!--- Set up the FTP configuration. --->

       

      <cfset objFTPProperties = {

      Server =

      "#application.RADARSftpServer#",

      Port =

      "#application.RADARSftpPort#",

      Username =

      "#application.RADARSftpUser#",

      Password =

      "#application.RADARSftpPassword#",

      Secure =

      true

      }

      />

       

       

      <cfset myConnection = createObject("java","org.apache.commons.net.ftp.FTPClient").init()>

      <cfdump

       

      var="#myConnection#">

       

       

      <cfftp

       

      action="open"

       

      connection="myConnection"

       

      attributeCollection="#objFTPProperties#"

       

      />

      <cfdump var="#myConnection#">

       

       

       

      <cfset siteCommand="chmod 777 #remoteCsvFile#_fromTest">

       

      <!--- <cfscript>myConnection.sendSiteCommand(javacast("String","#siteCommand#"));</cfscript> --->

       

      <cfscript>myConnection.sendSiteCommand("ls");</cfscript>

       

       

      <!--- <cfscript>myConnection.printWorkingDirectory();</cfscript> --->

       

       

      <cfftp connection="myConnection" action="close" stoponerror="Yes" passive="yes">

       

      </cfoutput>

       

       

       

      <cfset siteCommand="chmod 777 #remoteCsvFile#_fromTest">

       

      <!--- <cfscript>myConnection.sendSiteCommand(javacast("String","#siteCommand#"));</cfscript> --->

       

      <cfscript>myConnection.sendSiteCommand("ls");</cfscript>

       

       

      <!--- <cfscript>myConnection.printWorkingDirectory();</cfscript> --->

       

       

      <cfftp connection="myConnection" action="close" stoponerror="Yes" passive="yes">

       

      </cfoutput>

       

       

      <cfset siteCommand="chmod 777 #remoteCsvFile#_fromTest">

       

      <!--- <cfscript>myConnection.sendSiteCommand(javacast("String","#siteCommand#"));</cfscript> --->

       

      <cfscript>myConnection.sendSiteCommand("ls");</cfscript>

       

       

      <!--- <cfscript>myConnection.printWorkingDirectory();</cfscript> --->

       

       

      <cfftp connection="myConnection" action="close" stoponerror="Yes" passive="yes">

       

      </cfoutput>

       

       

       

       

      Is there a better way of doing this?  I do not have the option of setting a umask on the unix user account - so I need to do the set the file permissions here.  I looked into the new CF8 FileSetAccessMode method, but I cannot map a drive to this remote server - I only have ftp permission on the server.

       

      Thanks