Apache Commons Net - Retrieve File - Extension, Compare , Move - FTP Server

Dear All,
I am using Apache Commons net FTP Library for FTP Operations. I had a few doubts
1) I like to retrieve ftp files only with some extensions like *.txt or *.jpg etc. How can we retrieve files with specifying file extension?
2) I need to compare the FTP Files with the local files before downloading from the FTP Server?
3) I need to move files from the ftp server to local directory. Is there is anyway to move the files rather than first retrieve files from the FTP Server and then deleting the file in the FTP Server using FTP delete()
Thanks,
J.Kathiresan

1) I like to retrieve ftp files only with some
extensions like *.txt or *.jpg etc. How can we
retrieve files with specifying file extension?
List the files and then filter the list to those that you want to process.
2) I need to compare the FTP Files with the local
files before downloading from the FTP Server?Think about this one! To compare two files you nead to read both. If you do this on the client then you will have to copy the file from the server first!
>
3) I need to move files from the ftp server to local
directory. Is there is anyway to move the files
rather than first retrieve files from the FTP Server
and then deleting the file in the FTP Server using
FTP delete()What is wrong with copy then delete?

Similar Messages

  • Apache commons-net

    Hi
    I was using apache commons-net to FTP some files to an FTP server.
    I was able to login to the server. I want to know How can I move out from my root directory. Is it possible using apche coomons-net. The working directory displayed is only /home/myname.
    Thanks
    Prabhath Nair

    If you want to move to a sub-directory within your current root then could it possibly be the changeWorkingDirectory() command?
    P.S. You wont be able to move to some directory such as /etc because FTP servers constrain you to stay within a fixed root directory. Often, the home directory of the login name.

  • Apache Commons Net deployment fails to resolve, JDev classpath question

    I wrote a wrapper to apache's most recent version of commons-net package (version 1.4.1) to allow me to execute FTP services from an Oracle 9i2 database. After adding the common-net .jar file to the JDev libraries, and including this library in my project, I debugged the code in Jdeveloper, then deployed to the Oracle 9i2 server. However, many classes of the of the common-net (and my code) failed to resolve in the database.
    After downloading open source product DependencyFinder, and running against the Commons-net .jar file, I found that some packages were dependent on the Apache ORO regexp package. The ORO package, as far as I can tell, is not in any classpath that my JDev project uses. There is listed in the JDev libraries, a library called Apache Regexp, but I did not include that in the project, either.
    After I downloaded the ORO package from Apache, added it to JDev's libraries, included it in my project, and added the ORO library to the list of classes to deploy (using the loadjava deployment profile), deployment to Oracle 9i2 of the my classes, the commons-net classes, and the ORO classes properly resolved.
    My question is: Why did my application work under JDeveloper? How and where did it find the ORO classes?
    The version of Java under which JDeveloper is running, and the version being used as the compiler for this project, is a new installation of JDK1.4.2_10.

    Since the commons net 1.4.1 is compatible with jdk 1.3.1, I should only need to use loadjava on the .jar file. In fact, that works, given that there is no failure on load due to incompatible .jar or .class files structure.
    But, I've just solved this part of the problem. The commons net 1.4.1 is dependent on, but does not include the Apache ORO library. Once the ORO library was deployed to Oracle 9i2, all common net 1.4.1 classes were resolved.
    The "problem" is with JDeveloper. Without including the ORO library in the JDeveloper application, or in the classpath, it worked under JDeveloper -- the more surprising since I had never downloaded the ORO library from Apache. Only after downloading ORO, explicitly defining ORO to JDeveloper, and including ORO as a library in my JDeveloper project, did the deployment of the application to Oracle 9i2 succeed (though the application always executed successfully under JDeveloper).

  • Connect to FTP site with Apache commons net FTP client through Proxy

    Hello,
    I am trying to run this simple code to connect to FTP site through a proxy.
    import org.apache.commons.net.ftp.FTP;
    import org.apache.commons.net.ftp.FTPClient;
    public class MyTest {
    public static void main(String[] args) {
    String ftpHostName = "ftp.xxx.com";
    int ftpPort = 21;
    String ftpUserName = "myUserName";
    String ftpPassword = "myPassword";
    System.setProperty("socksProxyHost" ,"10.148.0.131");
    System.setProperty("socksProxyPort", "1080");
    FTPClient ftpClient = new FTPClient();
    try {
    System.out.println("connecting");
    ftpClient.connect(ftpHostName, ftpPort);
    System.out.println("connected");
    System.out.println("loging in");
    boolean successLogin = ftpClient.login(ftpUserName, ftpPassword);
    if(successLogin)
    System.out.println("success login");
    else
    System.out.println("fail login");
    catch (Exception e) {
    e.printStackTrace();
    finally {
    try {
    System.out.println("loging out");
    ftpClient.logout();
    System.out.println("disconecting");
    ftpClient.disconnect();
    catch (Exception e) {
    e.printStackTrace();
    I am getting the following error:
    C:\temp\ftp\test>java.exe -cp ./commons-net-ftp-2.0.jar;. MyTest connecting
    java.net.SocketException: Malformed reply from SOCKS server
    at java.net.SocksSocketImpl.readSocksReply(SocksSocketImpl.java:87)
    at java.net.SocksSocketImpl.connectV4(SocksSocketImpl.java:265)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:437)
    at java.net.Socket.connect(Socket.java:519)
    at org.apache.commons.net.SocketClient.connect(SocketClient.java:176)
    at MyTest.main(MyTest.java:23)
    loging out
    java.lang.NullPointerException
    at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:471<ftp://FTP.java:471>)
    at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:534<ftp://FTP.java:534>)
    at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:583<ftp://FTP.java:583>)
    at org.apache.commons.net.ftp.FTP.quit(FTP.java:794<ftp://FTP.java:794>)
    at org.apache.commons.net.ftp.FTPClient.logout(FTPClient.java:697)
    at MyTest.main(MyTest.java:39)
    I am able to do this using a different FTP client library, ftp4j-1.5.1<ftp://ftp4j-1.5.1> using the following code:
    import it.sauronsoftware.ftp4j.FTPClient;
    import it.sauronsoftware.ftp4j.connectors.SOCKS4Connector;
    public class MyTestFtp4J {
    public static void main(String[] args) {
    String ftpHostName = "ftp.xxx.com";
    int ftpPort = 21;
    String ftpUserName = "myUserName";
    String ftpPassword = "myPassword";
    FTPClient ftpClient = new FTPClient();
    ftpClient.setConnector(new SOCKS4Connector("10.148.0.131", 1080));
    try {
    System.out.println("connecting");
    ftpClient.connect(ftpHostName, ftpPort);
    System.out.println("connected");
    System.out.println("loging in");
    ftpClient.login(ftpUserName, ftpPassword);
    System.out.println("success login");
    catch (Exception e) {
    e.printStackTrace();
    finally {
    try {
    System.out.println("disconecting");
    ftpClient.disconnect(true);
    catch (Exception e) {
    e.printStackTrace();
    So I know the proxy settings are correct.
    The java version I used to compile and run my apps is 1.6.0_06 Does anyone can help figure out what is wrong when I use the Apache commons net FTP client?
    Thank you
    Jon

    Is the old AirPort Extreme base station (AEBS)
    configured so that the option to distribute IP
    addresses is DISABLED? If so, configure the new AEBS
    to act as a bridge.
    Are you suggesting I use a set-up with TWO AEBSs? Set up a bridge (not sure how) and then use the old AEBS to connect to the DSL modem and broadcast to the new Extreme which will then be the router to the other computers on the network?
    Do you have any port mapping or default host enabled
    on the old AEBS?
    I do not understand, not do I see these options in the Base Station utitlity; perhaps they are in the FTP options--but that, I'm sorry to say, is not obvious to my inspection.
    Duane, can you give me a few more basic instructions? Thanks
    iMac 17    

  • IPod Touch 5Gen movie file extension is MOV.mov - why?

    I noticed when I recorded a movie today, the file extension was .MOV.mov  . I've never seen this before. I can watch it fine.
    When I record using my iPad 2, the movies just have .MOV as the file extension.
    Is this a glitch and if so, how to fix it? ( I'm wondering if people who I send the recording to will be able to view it.)
    Thanks.

    No, I didn't. I sent the movies to my computer via text (imessage).
    I just decided to sync/upload them via iPhoto and the file extension is now .MOV
    Have you any idea what changes it when it's sent via imessage on device to imessage on computer?

  • XML File Creation Problem in FTP Server

    Hi.. Experts
    My Internal Table is as follows
    Types: Begin of ty_xmlfile,
             xmlline(60000)        type C,
           End of ty_xmlfile.
    Data: it_xmlfile type standard table of ty_xmlfile,
            wa_xmlfile type ty_xmlfile.
    When I download the file to my desktop using  GUI_DOWNLOAD. It works fine
    CALL FUNCTION 'GUI_DOWNLOAD'
              EXPORTING
                BIN_FILESIZE = lv_size
                FILENAME     = lv_file_name
                FILETYPE     = 'ASC'
              TABLES
                DATA_TAB     = it_xmlfile
              EXCEPTIONS
                OTHERS       = 10.
            IF SY-SUBRC <> 0.
              MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
            ENDIF.
    In the debug mode when I download the internal table(IT_XMLFILE) into an excel file it doesn't open and it says tag is missinig(/basic_material_text) and also when I create the file in Application Server and transfer it to FTP Server it doesn't open there..and also in debug mode I find the length until  DIMENSION AN.. for that row when I double click on that line in debug mode it shows all the text until </baisc_material_Text>
    <basic_material_text>4.500 +.000/-.010 O.D. X 213.0&quot; LG.(F)                      (A)ASTM A276 CONDITION &quot;A&quot; 317LTYPICAL MILL CERTS REQ&apos;D.DIMENSION REFERENCE:(A) = ALLOWANCE IS INCLUDED FOR MACHINING(F) = THIS IS A FINISHED DIMENSION AN*
    The above statement is incomplete when the file is open in FTP Server.
    But when the file is created on to my desktop. It displays all the text....
    <basic_material_text>4.500 +.000/-.010 O.D. X 213.0" LG.(F) (A)ASTM A276 CONDITION "A" 317LTYPICAL MILL CERTS REQ'D.DIMENSION REFERENCE:(A) = ALLOWANCE IS INCLUDED FOR MACHINING(F) = THIS IS A FINISHED DIMENSION AND WILL BE USED AS RECEIVED(T) = TO FINISH TO THIS DIMENSION FOR FORGING AND BILLET MATERIAL ONLYVENDOR TO SUPPLY THE FOLLOWING ENGINEERING/QUALITY ASSURANCE DATATYPICAL MILL TEST CERTIFICATES/CERTIFICATES MUST ACCOMPANY THE MATERIAL.* COPIES REQUIRED:(2)ALL CERTIFICATES MUST HAVE LIGHTNIN PART NO.CLEARLY MARKED ON THEM.* COPIES REQUIRED:(2)</basic_material_text> *
    I could not understand why it takes only until DIMENSION AN
    Any suggestions would be very helpful...
    Thanks,
    Chaitanya
    -Points will be awarded for helpful answers.

    Hi...
    I think each XML Line will be of length 256. So I have to split the String into 256 of each Line.
    XML DOM Processing in ABAP part I -  Convert an ABAP table into XML file using SAP DOM Approach.
    Hope  it works out....I will try for that and Close the Post...
    Thanks,
    chaitanya K

  • Automate a BI report to flat file on to a FTP server.

    Hello all,
    I have an same issue like the following thread. After extract CSV file successfully to the directory, but unable to find the file. Any thought?
    Automate a BI report to flat file on to a FTP server.
    Regards!

    Need to analyze the business purpose ,however heres my take on it..
    You can utilize 3 options to export query result on to the SAP directories as below and map that path to your FTP server.
    1. Transaction RSCRM_BAPI (still valid in nw2004s)
    2. Transaction RSANWB (analytical Process designer)
    3. Information Broadcasting - KM folder has to be mapped as a file system location.
    Hope it Helps
    Chetan
    @CP..

  • Commons Net - List files with more than a wildcard "*" in path

    Hello everybody!
    I�m starting to use commons net library in a java project, and I have this doubt: I need to list files in a ftp server, for instance, like this �action*/slot*-qual*.txt�
    i.e., I want to list all the files like �slot (something) � qual (something) .txt�, in all directories beginning with �action (something)�.
    When I put this path in a variable named �path� and pass it to the listFiles method, it returns me a list of zero files. But, for instance, if I only pass the path �action*�, the listFiles returns me all the directories beginning with �action�, like action01, action02, etc. The same happens if I pass only �slot*-qual*.txt�, giving me all the files that respect the command, within a certain directory, like slot1-qual101010.txt, slot2-qual10.txt, slot3-qual1.txt, etc.
    So, there�s must me a method to do this kind of listing, isn�t it? Is it possible to list the files like this?
    If I put the command �ls action*/slot*-qual*.txt� in an ftp client that I use, I get the correct list that I need, so it works like this!
    Thanks a lot everybody!
    Andr� Augusto
    FTPClient ftp;
    FTPFile[] files;
    files=ftp.listFiles(path);
    for (int i=0; i<files.length; i++)
    logger.info("Index: "+i+ " -> Name: " +files.getName());

    Hello everybody!
    I�m starting to use commons net library in a java project, and I have this doubt: I need to list files in a ftp server, for instance, like this �action*/slot*-qual*.txt�
    i.e., I want to list all the files like �slot (something) � qual (something) .txt�, in all directories beginning with �action (something)�.
    When I put this path in a variable named �path� and pass it to the listFiles method, it returns me a list of zero files. But, for instance, if I only pass the path �action*�, the listFiles returns me all the directories beginning with �action�, like action01, action02, etc. The same happens if I pass only �slot*-qual*.txt�, giving me all the files that respect the command, within a certain directory, like slot1-qual101010.txt, slot2-qual10.txt, slot3-qual1.txt, etc.
    So, there�s must me a method to do this kind of listing, isn�t it? Is it possible to list the files like this?
    If I put the command �ls action*/slot*-qual*.txt� in an ftp client that I use, I get the correct list that I need, so it works like this!
    Thanks a lot everybody!
    Andr� Augusto
    FTPClient ftp;
    FTPFile[] files;
    files=ftp.listFiles(path);
    for (int i=0; i<files.length; i++)
    logger.info("Index: "+i+ " -> Name: " +files.getName());

  • Uploading large file to iCloud & move to Server

    Hi, is there a way to set up iCloud to share a large file from a client with our company, so that we can move that file from iCloud to our server? Any help would be appreciated. Thanks.

    No

  • Export Table to flat file and upload to FTP server for external vendor

    I have done some extensive searches on the forums and I think I have an idea but really need some help. Basically have a table that needs to be exported to a flat file and uploaded to a FTP server so that our vendor can get the data Monday-Saturday and automated by sysdate. This data is used to produce daily letters that go out to customers.
    After doing some searching I came across the UTL_FILE package and reading more into this right now but I am not sure if it is what I should be using to create the file.
    I am using TOAD right now and can see how to do it manually however really need the file to create itself and send automatically at 6 am Monday - Saturday with the date at the end of the file name making it a unique file for each day.
    Thanks in advance for all of your help.

    As Justin and others have mentioned I wrote [XUTL_FTP|http://www.chrispoole.co.uk/apps/xutlftp.htm] so you wont find it in the Oracle documentation. It's pure PL/SQL and uses UTL_TCP and implements an integrated PL/SQL FTP client / API. One of it's many overloaded procedures FTP's the contents of a refcursor straight to a FTP server of your choice, meaning no intervening file is required. Since it is pure PL/SQL, it is trivial to schedule using DBMS_JOB/DBMS_SCHEDULER.
    Any questions just ask.
    HTH Chris

  • File transfer from a FTP server to another External FTP server

    Hi,
    I have one FTP server , I need to transfer a file from this FTP server to aother external FTP server. Could any one please help me how to write a batch file on FTP server so that my file is transfered to another FTP server by executing the Batch file. I don't want to use SAP server for this.
    best regards
    bobby

    CREATE CONTROLFILE
    Caution:
    Oracle recommends that you perform a full backup of all files in the database before using this statement. For more information, see Oracle9i User-Managed Backup and Recovery Guide.
    Purpose
    Use the CREATE CONTROLFILE statement to re-create a control file in one of the following cases:
    All copies of your existing control files have been lost through media failure.
    You want to change the name of the database.
    You want to change the maximum number of redo log file groups, redo log file members, archived redo log files, datafiles, or instances that can concurrently have the database mounted and open.
    Note:
    If it is necessary to use the CREATE CONTROLFILE statement, do not include in the DATAFILE clause any datafiles in temporary or read-only tablespaces. You can add these types of files to the database later.
    An alternative to the CREATE CONTROLFILE statement is ALTER DATABASE BACKUP CONTROLFILE TO TRACE, which generates a SQL script in the trace file to re-create the controlfile. If your database contains any read-only or temporary tablespaces, that SQL script will also contain all the necessary SQL statements to add those files back into the database.
    http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96540/statements_54a.htm#SQLRF01203

  • Transfer file to an external FTP SERVER

    HI Gentelemen!!,
    I'm trying to open an external FTP connection, sending a file from the  MiniSAP.
    Which is the appropiate RFC connection that I have to use??
    Anybody know how to set RFC connection to access an external FTP server.
    This are the MF that I use:
    CALL FUNCTION 'SCRAMBLE_STRING'
    To encrypt password
    CALL FUNCTION 'FTP_CONNECT'
    here i have an import value for RFC DESTINATION
    return handle - I use it to close the connection
    CALL FUNCTION 'FTP_COPY'
    CALL FUNCTION 'FTP_DISCONNECT'
    Use HANDLE numbre to close the connection
    Thanks for your help.
    POLAK.-

    I am not sure minisap has sapftp and sapftpa executable.
    Anyway the two RFC destination used to do FTP are SAPFTPA and SAPFTP. This are 2 TCP/IP RFC destination (Type T) that launch either the program sapftp or sapftpa on the application server.
    If these rfc destination are not setup in transaction SM59 you can try to define them but it might not work on minisap.
    Regards

  • Placing the File in ISeries AS400 FTP Server

    Hi,
    I am working in IDOC to file Scenario and trying to append the Records in the flat file in AS400 FTP Server Directory.
    I am unable to place to file in the FTP Server and getting the error message as below.
    Message processing failed. Cause: com.sap.engine.interfaces.messaging.api.exception.MessagingException: An error occurred while connecting to the FTP server 'xx.xx.xxx.xxx:21'. The FTP server returned the following error message: 'com.sap.aii.adapter.file.ftp.FTPEx: 501  File identifier not valid in MKD subcommand.'. For details, contact your FTP server vendor
    Please provide your valuable suggestion on this.

    Now I am getting the error message as below
    Delivering the message to the application using connection File_http://sap.com/xi/XI/System failed, due to: com.sap.engine.interfaces.messaging.api.exception.MessagingException: An error occurred while connecting to the FTP server xx.xx.xxx.xx:21'. The FTP server returned the following error message: 'com.sap.aii.adapter.file.ftp.FTPEx: 426 Unable to open or create target file SPD3INTMCD.txt in library FTPLIB. Data transfer ended.'. For details, contact your FTP server vendor..
    Please suggest on this.

  • File not coming at FTP server

    Hi,
    I am doing Idoc to File scenario...In receiver communication channel FTP server is to be used...Data is processing successfully in sxmb_moni...but its not visible at FTP server....have checked at all the places...
    Please help.

    this can be for the following reasons...
    1. your File adapter might throw some error ( check RWB-->Adapter monitoring)
    2. Data might be stuck in Queue ( TO-BE-Delivered state) cehck in adapter engine or cache
    3. Since you are sending data to the remote server, it's so happens sometimes if the idle time is more from one file is sent and for another file it the gap is more then you might have to reactivate the file adapter and run the interface.
    4. Check is there any batch file running on the FTP by legacy which are moving the files form that location...
    5. Make Sure you are sending the data ( No empty files Careated).

  • How to display read file and put in ftp server in jsp

    Hi all
    since this is very importent question, please understand it and reply soon.
    i am using power analyzer sdk. front end as jsp.
    i want read a file using poweranalyzer sdk(how to read this?)and put it in ftp server(how to put this?)
    thanks and regards
    Kasim
    Bangalore

    http://java.sun.com/docs/books/tutorial/uiswing/components/editorpane.html

Maybe you are looking for

  • Cisco vpn client issue on windows 8.1 pro

    I am using Cisco RV325-k9 router, I am configure "Easy vpn" in this router. Our some users use Windows 7 pro and others users use Windows 8.1 pro with Cisco vpn client version 5.0.070290. Issue is VPN client connected but not access remote machine an

  • Preserving spaces in XSLT Mapping

    Hi ,     My source structure has a field <field1>     aaaa1234</field1> whens this field is transformed by using a XSLT mapping the output is as follows <field1>aaaa1234</field1> This output is visible in the interface mapping itself. The leading spa

  • Clearing vendors/customer with S/L indicators

    Hi, I'm tring to clear two items (with S/L indicatrs) with difference. I would that the automatic item, in which is posted the difference, use the S/L indicator too. At the moment this not happened: the system use a different PK (without S/L indicato

  • MDM PUBLISHER ERROR

    Hi,          when i am trying to open MDM publisher , I am getting error XERCES-C_2_6.DLL  was not found. How to get rid of this problem.

  • Sites gone from site list in DW8

    Hey All- So, I did some searching on the issue, there seem to be a lot of people with similar issues throughout the years, but as far as I can tell, no real solutions provided. The issue I am having is that everytime I Launch Dreamweaver 8, all of my