Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to get a file with <CFFTP>

Guest
Sep 02, 2010 Sep 02, 2010

I am trying to grab a file and move it to the coldfusion server using <CFFTP> The server in which I am trying to grab the file is a sftp server. I am running coldfusion 8. When I run my code, I dont get an error, I just get a blank white screen, yet the file has not been moved. I will post my code below, does anyone know what I am doing wrong?


<!--- Open conncetion with remote sftpserver --->

        <cftry>
            <cfftp action="open"
                connection="ftpServer"
                server="server.com"
                username = "username"
                password = "password"
                fingerprint = "11:11:B5:F2:11:AF:C2:E2:31:11:D3:B4:11:83:11:11"
                timeout="20"
                port="22"
                secure = "yes" />
            <cfcatch>
                <cfset throwFileTransferFailed("Could not open connection. Message: " & cfcatch.Message & ". Detail: " & cfcatch.Detail)>
            </cfcatch>
        </cftry>

<!--- get the file --->

        <cftry>     
               <cfftp
                action="getFile"
                connection="ftpServer"
                server="server.com"
                username="username"
                password="password"
                remotefile="TEST_20100816.csv"
                localfile="C:\WENS_DEV\pdf\"
                failIfExists="no">
            <cfcatch>
                <cfset throwFileTransferFailed("Could not open connection. Message: " & cfcatch.Message & ". Detail: " & cfcatch.Detail)>
            </cfcatch>
        </cftry>

1.6K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Sep 02, 2010 Sep 02, 2010

Things to try:

1. The value of localfile attribute should probably be a full path including the name of the file, not just a directory.

2. You should be able to omit the username and password in the getFile CFHTTP tag since you're using an existing connection.

3. Does the CF service have sufficient rights to write files to the C:\WENS_DEV\pdf\ directory?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 02, 2010 Sep 02, 2010

how do I tellif the CF service has sufficient rights?

Now my code looks like this and I am still getting an error. I cant figure it out.

            <cfftp action="open"
                connection="ftpServer"
                server="server.com"
                username = "username"
                password = "password"
                fingerprint = "11:11:11:11:11:11:11:11:11"
                timeout="30"
                port="22"
                secure = "yes" />
   
               <cfftp
                action="getFile"
                connection="ftpServer"
                remotefile="TEST_20100816.csv"
                localfile="C:\WENS_DEV\pdf\TEST_20100816.csv"
                failIfExists="no">

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 02, 2010 Sep 02, 2010

After you open the ftp connection, try a listdir.  If nothing else it should tell you that your connection was successful and what's available on the other end.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 02, 2010 Sep 02, 2010

crap, I didthat and it is still not working.

Here is my code for the listdir

                <cfftp action="LISTDIR"
                           stoponerror="yes"
                           name="client_file"
                           directory="/"
                           connection="ftpServer">
                       
                           <cfoutput query="client_file">
                           #LAST_NAME#<br />
                           </cfoutput>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Sep 02, 2010 Sep 02, 2010

The results of a listDir CFFTP call, which is a query object, would not contain a "LAST_NAME" column. See the CF docs for more info.

http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Tags_f_20.html#3490627

What are you trying to accomplish here?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 02, 2010 Sep 02, 2010
LATEST

When troubleshooting, cfdump is a much better tag to use than cfoutput.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Sep 02, 2010 Sep 02, 2010

The CF account runs under a user login or account of some kind. The terminology would depend on the operating system you are using. Are you using Windows or *nix?

What error message(s) are you receiving?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 02, 2010 Sep 02, 2010

I am using windows.

Here is the kicker, I am in a new position, working in someone elses system, and the way it is set up, no matter what error accurs, a nice little friendly error with the company logo pops up. I can't see anything. Even when I use <Try> <catch>, I get nothing.

I will certainly be bald before this is over.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Sep 02, 2010 Sep 02, 2010

IF you have access to the ColdFusion logs, either through the administrator OR through a network file system, you could look up the copy of the error that ColdFusion stores, even though it is not being displayed in the browser.

ALSO, depending on how they are causing that friendly error with the company logo, you may be able to circumvent it with an <CFABORT> tag.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 02, 2010 Sep 02, 2010

Checking the logs is a great idea, I will do that. Ill bet the answer is in there. Thanks everyone!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Sep 02, 2010 Sep 02, 2010

If you have access to the CF Administrator, you can add your IP address to the list of addresses that display verbose error messages rather than the useless ones that typical end users might see.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources