Monday, July 27, 2015

CFFTP listdir fails when SYST command is disabled on remote FTP server

In this blog article we are going to discuss an issue which prevents CFFTP to display list of folders and files retrieved from FTP server when SYST command is disabled on the remote FTP server.

Let's look at why this issue is happening when SYST command is disabled. CFFTP for listing the directories and files (action="listdir") from the remote FTP server invokes ftp list command. Remote ftp server executes issued list command and sends the directory listing as part of the response. Once CFFTP receives the response it needs to perform the parsing and represent it as a listing. But the parsing of the response depends on the file list layout style of the remote FTP server. FTP provides this information through SYST command using which CFFTP knows how to parse the the listing response.

Many ftp servers disable this SYST command as it reveals the target ftp server information and its OS type.  Then in this case the request for listing will fail. But there is a way to override this behaviour of not calling SYST command with a JVM flag named org.apache.commons.net.ftp.systemType. If this jvm flag is specified with a value which specifies how to parse list command response, SYST command will not be invoked and parsing happens as specified in the JVM flag. But if the CF instance is connecting to multiple remote FTP servers hosted on different operating systems which does not allow SYST command setting this flag will result in errors which lead us to add a new attribute to the CFFTP tag.

A new attribute has been added to CFFTP tag called systemType which specifies how to parse the file list response without invoking SYST command. This attribute is available from CF11 update 3.

Possible values for the attribute are (The same values are also applicable for the JVM flag)
     WINDOWS: if specified CFFTP treats the response as Windows-Style directory listing
      UNIX:  if specified CFFTP treats the response as Unix-Style directory listing
     Also, can specify any class name which implements org.apache.commons.net.ftp.FTPFileEntryParser

The attribute can be set at multiple levels one during the connection open operation or when doing any of the FTP operation like listdir.  If this attribute is set during named ftp connection then the systemtype will be used across all ftp operations  where systemType is left unspecified.

Lets take a look at an example. For this example purpose i am using IIS ftp server and disabled the SYST command as shown in the screenshot.


then ran the below script to retrieve the files from this ftp server.
<cfscript>
ftpService = new ftp(server = "localhost", username = "pavan", password="P#$a12$3", connection="myconn");
files = ftpService.listdir(directory="/", connection="myconn", name="files");
writeDump(files);
files = ftpService.listdir(directory="/sample", connection="myconn", name="files");
writeDump(files);
</cfscript> 
Running the above script thrown the below error saying that the remote ftp server does not allow SYST command



To fix this add the systemtype attribute to the listdir operation and run the example
<cfscript>
ftpService = new ftp(server = "localhost", username = "pavan", password="P#$a12$3", connection="myconn");
files = ftpService.listdir(directory="/", connection="myconn", name="files", systemtype = "WINDOWS");
writeDump(files);
files = ftpService.listdir(directory="/sample", connection="myconn", name="files", systemtype = "WINDOWS");
writeDump(files);
</cfscript>
Now the script executes successfully and returns the listing

This code further can be optimized by specifying the systemtype at the named connection level (then no need to specify at listdir operation)

<cfscript>
ftpService = new ftp(server = "localhost", username = "pavan", password="P#$a12$3", connection="myconn", systemtype = "WINDOWS");
files = ftpService.listdir(directory="/", connection="myconn", name="files");
writeDump(files);
files = ftpService.listdir(directory="/sample", connection="myconn", name="files");
writeDump(files);
</cfscript>
 Here is the order how CFFTP looks for System Type
1) Checks if there is any systemtype specified at the tag/script. If found uses it for parsing
2) Otherwise looks at the JVM flag org.apache.commons.net.ftp.systemType if any value specified uses it.
3) As a last resort invokes SYST command if SYST command is unsuccessful listing fails otherwise listing is successful.

Thanks,
Pavan Kumar.


34 comments :

  1. These blog is very informative and mind blowing. I think everyone should know such that information like you have described on this post.

    Hadoop Training in Chennai

    ReplyDelete
  2. Be sure that after reading advices from https://resumecvwriter.com/blog/how-to-write-resume-job-description you will write quite good resume job description. It will help you to impress your employer.

    ReplyDelete
  3. Nice article. Highly recommended. The thoughts are clear and well explained. Thankyou for sharing your work, truly worth reading. On the other hand, if you’re interested in , Blinds Singapore , feel free to visit our website. Thankyou and Godbless!

    ReplyDelete
  4. This is an awesome post.Really very informative and creative contents. These concept is a good way to enhance the knowledge.I like it and help me to article very well.Thank you for this brief explanation and very nice information.Well, got a good knowledge.
    DedicatedHosting4u.com

    ReplyDelete
  5. I love your article so much. Good job
    Participants who complete the assignments and projects will get the eligibility to take the online exam. Thorough preparation is required by the participants to crack the exam. ExcelR's faculty will do the necessary handholding. Mock papers and practice tests will be provided to the eligible participants which help them to successfully clear the examination.

    Excelr Solutions

    ReplyDelete
  6. If you occur to find any trouble with your printer, troubleshoot by referring to resolutions of respected error. Not only hp printer in error state but our technical experts can assist you to fix this failure by providing online remote help.
    https://hprinterofficial.com/blog/hp-printer-in-error-state-windows-10/

    ReplyDelete
  7. You should go for the virtual reality app development company India i.e. Appknock if you really want the best virtual reality app development services for your project. As there are many companies who are able to provide the best vr app development services but you should go for the best. Many of the companies who deliver expensive services but first you should analyze how much does app development cost. Because only this analyzation helps you to get the best vr app development services at affordable prices. You should search that how ar transform the mobile gaming market. You’ll understand its importance.

    ReplyDelete
  8. Are you searching for the commercial property solicitors? Then look no further than AI international law firm. They have experienced solicitors in the UK to help immigration, real estate, private and commercial law cases. For more information, feel free to visit their website.

    ReplyDelete
  9. The very next time I read a blog, Hopefully it doesn't fail me as much as this particular one. I mean, I know it was my choice to read through, however I truly believed you would probably have something helpful to say. All I hear is a bunch of whining about something that you can fix if you were not too busy searching for attention. onsite mobile repair bangalore Spot on with this write-up, I actually believe that this website needs far more attention. I’ll probably be returning to see more, thanks for the info! asus display repair bangalore You are so awesome! I don't suppose I've truly read something like this before. So good to discover someone with original thoughts on this subject. Really.. thank you for starting this up. This site is one thing that is needed on the internet, someone with a little originality! huawei display repair bangalore

    ReplyDelete
  10. There is certainly a great deal to find out about this subject. I love all the points you have made. online laptop repair center bangalore You made some really good points there. I looked on the internet to find out more about the issue and found most people will go along with your views on this web site. dell repair center bangalore

    ReplyDelete
  11. Having read this I believed it was rather enlightening. I appreciate you finding the time and energy to put this information together. I once again find myself personally spending a significant amount of time both reading and commenting. But so what, it was still worthwhile! macbook repair center bangalore Hi! I could have sworn I’ve been to this website before but after browsing through many of the posts I realized it’s new to me. Anyhow, I’m definitely pleased I came across it and I’ll be bookmarking it and checking back regularly! acer repair center bangalore

    ReplyDelete
  12. At the point when you're attempting to get in shape, you need to ensure that your eating regimen is working for you. That is the reason you ought to be taking an enhancement called keto formation pills diet pills.

    https://deliver4superior.com/

    ReplyDelete
  13. Law Assignment Help

    We at Fullassignment.com bring to you the most significant Law assignment help writing service at the best cost. With long stretches of understanding we are prepared to give assignment help over the globe.You will be guided here with a portion of the information of law assignment which could assist you in deciding writing a law assignment. Nonetheless, we unequivocally prescribe you to benefit Business law Homework help from our specialist to find out about marketing and its scope.We also provide Biotechnology Assignment help from our experts.

    https://fullassignment.com/

    ReplyDelete
  14. This is an awesome post.Really very informative and creative contents. Thanks for sharing...
    Digital Marketing in Bangalore

    ReplyDelete
  15. I like how this article is written. Your points are sound, original, fresh and interesting. This information has been made so clear there's no way to misunderstand it. Thank you.
    Best Data Science training in Mumbai

    Data Science training in Mumbai

    ReplyDelete
  16. Hello budiies! I can agree with every word on this topic! Pupils may even find all the information about correct spam filters at online paper writing service, simply check their bestresearchpaper.com webpage. There are a lot of professional editors with any topic you need to do in your university, college or school!

    ReplyDelete
  17. I love twitter because it's cool, I really like it, a lot of interesting and useful information in it. https://paramountessays.com/research-proposal-writing-service

    ReplyDelete
  18. Hi dudes! I recommend using this service if you need to quickly write or finish a written assignment. From my own experience, I can say that to write a quality essay, you need to spend a lot of time. Since I work, I don't have enough free time, so I sometimes use this service. The level of essays from Master Papers service is high and I was able to successfully pass these assignments at the university

    ReplyDelete
  19. What a great article!. I am bookmarking it to read it over again after work. It seems like a very interesting topic to write about.
    SAP training in Kolkata
    SAP training Kolkata
    Best SAP training in Kolkata
    SAP course in Kolkata
    SAP training institute Kolkata

    ReplyDelete
  20. Thanks for provide great informatic and looking beautiful blog, really nice required information & the things i never imagined and i would request, wright more blog and blog post like that for us. Thanks you once agian

    name change procedure in ghaziabad
    name change procedure delhi
    name change procedure gurgaon
    name change in faridabad
    name change in noida
    name change
    name change in india
    name change procedure in bangalore
    name change procedure in rajasthan
    name change procedure in maharashtra

    ReplyDelete
  21. Great Content. Really impressive article I have ever read. Thanks for sharing. keep writing these type of articles and help people to get more knowledge.


    Activate PBS Channel
    pbs.org/activate

    ReplyDelete
  22. Hi there! Some months ago I have got an essay from one writing company that are doing classy tasks and there is nothing to add. Even for my tutor of chemistry has nothing to add about the quality of their super professionalism. Maybe chemistry is really an exciting subject for learners?! Just have a look at this online https://essaywriter.org/ service if you would like to know more information.

    ReplyDelete

  23. if you are searching for the best treatment at affordable in India so you need best doctors first. we hee to provide the best doctors from all over India at a very nominal cost.

    Regards

    Top Doctors in india

    ReplyDelete
  24. Awesome Blog with informative concept. Really I feel happy to see this useful blog, Thanks for sharing such a nice blog...
    Best Digital Marketing Courses near me

    ReplyDelete
  25. A printer driver or a print processor is a piece of programming on a PC that changes the information over to be printed to an format that a printer can comprehend. Obsolete printer drivers is one reason for printers to show a mistake. You can just go to the site and download and introduce the driver. Normal inspection of the printer driver is recommended, to know about when to refresh it.
    canon Printer in Error State windows 10

    ReplyDelete
  26. We are helping amazon seller's to reinstate their suspended seller account. Aplus global ecommerce is guide companies to write perfect amazon appeal letter and full proof amazon suspension appeal.

    amazon suspension appeal

    ReplyDelete
  27. Cara mengecilkan perut The habit of skipping breakfast in the morning can cause you to gain weight. The body's weight is rising, causing the stomach to expand. Furthermore, Ngobrol Sehat the morning habit can deplete the body's energy. As a result, make it a practice to have breakfast before beginning your activity. After 8 p.m.
    Ngobrol Sehat
    Ngobrol Sehat
    Ngobrol Sehat
    Ngobrol Sehat
    Ngobrol Sehat
    Ngobrol Sehat

    ReplyDelete
  28. Nice post. Please do visit a profile Click Counter a great profile learn more about click counts.

    ReplyDelete
  29. Get the answer for the query “ How To Get a Job in Infosys as a Fresher? ” with the real-time examples and best interview questions and answers from the best software training institute in Chennai, Infycle Technologies. Get the best software training and placement with the free demo and great offers, by calling +91-7504633633, +91-7502633633.

    ReplyDelete
  30. ทางเข้าpg soft slots games มีเกมให้สำหรับทุกคน PG SLOT แล้วก็ทุกๆรสนิยม คณะทำงานของพวกเราได้ปรับปรุงฟีพบร์มากหลายแบบเพื่อตอบรับกับเกมเมอร์ทุกแบบเพื่อทุกคุณได้รับประสบการณ์ที่ดี

    ReplyDelete