Placing file in a folder on FTP

Hi,
Could any body please guide me about the following query:
Can we directly place a file to a folder on the FTP through my ABAP program or i need to use Connect and then FTP_COPY.
Please guide.
Thanks and Regards

Hello,
After establishing a connection , first set the path where you want to place the contents of an internal table on the location on the FTP. To change the directory path
CONCATENATE 'cd ' lv_path INTO lv_cmd SEPARATED BY space.
lv_path contains the path on which you need the file.
CALL FUNCTION 'FTP_COMMAND'
   EXPORTING
     handle                = lv_handle
     command               = lv_cmd
   TABLES
      data                  = mdata[]
   EXCEPTIONS
     tcpip_error           = 1
     command_error         = 2
     data_error            = 3
     OTHERS                = 4
Now the directory is the where you need the file to be placed.
Now call the FM FTP_R3_TO_SERVER . Pass the handle and filename with internal table to this FM
Regards,
Sachin

Similar Messages

  • Archiving  file in different folder in sender file adapter

    Hi,
    I have a requirement in witch i have to pick 7 different file from seven different folder.
    for this I am using advance selection tab and defining all the other folder path.
    but my problem is I have to archive the different file in different folder .
    For exm..
    /folder1/file1.txt need to be archive in /archive_filder1/file1.txt
    /folder2/file2.txt need to be archive in /archive_filder2/file2.txt
    /folder3/file3.txt need to be archive in /archive_filder3/file3.txt
    can any one tell me that how to  define the dynamic  archive folder path??.
    regards,
    Navneet

    Hi Navneet
    In File Access parameters --> Target Directory
    Use this type of Directory name
    \XIDEV_STORES\%store%\sapoutbound
    here %store% will be changed accordingly
    e.g. if file will come for store 001 then this %Store% will be replaced by 001 and file will be placed in this 001 folder and if file will come for store 002 then this %Store% will be replaced by 002 and file will be placed in this 002 folder over FTP.
    For to achieve this Go to Advanced tab 
    For Variable Substitution check mark Enable
    Now speciofy the parameter values for Variable Name and Reference
    Under Vriable name specify = store
    Under Reference specify = payload:WP_PLU02,1,IDOC,1,EDI_DC40,1,RCVPRN,1     -
    You have to give full path name here that where this store variable is located into IDOC.
    Hope this example will help you
    Regards
    Dheeraj Kumar

  • FTP-File : move file from a folder to another

    Hi experts,
    Here is the deal :
    I have a FTP folder (OS windows) where my files are stored. As I want XI to pick them one by one, I need a way to move them one by one in another folder of the FTP before message processing, folder that will be polled by XI
    How can I do that ?
    more concretly :
    I have 5 files in a folder called Standard, files are named : TEST1_hhmmss.xml, TEST2_hhmmss.xml, etc.
    I have another folder, lets say Standard_child that XI scans every 5 minutes. As I want my 5 files to get picked one by one every 5 minutes, I need a way on the FTP before message processing that moves TEST1_hhmmss.xml in folder Standard_child then XI picks up this file, and so on until all files are consumed.
    Thanks a lots for any help, ive been struggling for days... so far I tried with a script that renames file before, but did not work on FTP...
    Kind regards,
    Jamal

    Hi
    This site may be helpful
    http://www.computing.net/answers/programming/batch-to-move-file-by-sysdate/14939.html
    you can check the net for more answers
    1) make a logic & ensure that ur script works fine in your sender system (where all files will be placed)
    2) you can try it urself if you have access to the systems command prompt
    3) use scheduler, of your sender system (you said it is windows) you can check help to see how you can schedule programs - there call your script.
    4) now your script will send the files to child folder one by one as per your logic, which can be picked by XI
    Regards
    Vishnu

  • 10.4.8 -- Files Dragged Onto Folders Are Placed WAAAAY Down The Folder

    Hey.
    Ever since upgrading from 10.4.7 to 10.4.8, many folders are now behaving weirdly.
    In 10.4.7, if I were to drag-drop a jpg file, for example, onto a closed folder, it would be automatically placed inside the folder in the nearest vacant space. Now, in most cases, whether it is one file or multiple files being simultaneously dragged-dropped onto a closed folder, the files are dispersed wildly, a lengthy stretch down the folder in area that previously wasn't used (didn't exist) and had no files placed that far down.
    I used Snapz Pro to record a quick example of a miscelaneous folder, showing the wild dispersal of new files that were drag-dropped onto an old closed folder. The only items in the old folder prior to the drag-drop, was the row of image icons visible at the top of the folder. The lengthy stretch downward of wildly placed files was created when those new files were drag-dropped onto the closed folder.
    The video is viewable at YouTube, here [ http://www.youtube.com/watch?v=MHl3tfxfwBs ]. It's kind of blurry because the video pixel size was shrunk by YouTube to their default screen size. But you can see the icons, the mouse's cursor dragging the scroll bar downward, etc. Please take a quick look. It's only 15 seconds long.
    Is anyone else experiencing this? It is REALLY ANNOYING! I plan on writing Apple's feedback and making a complaint. But I figured I would ask here first and see if anyone else noticed this.
    17" iMac G4, 1GHz PowerPC, 768mb RAM   Mac OS X (10.4.8)  

    I would have to say, no arrangement. I don't know where to set "name, date modified, date created, size, etc." for folders.
    It does it with brand new folders also. And with folders created after the upgrade. But it doesn't do it with all folders, either pre-10.4.8 or post.
    I'm going to run a Repair Disk Permissions later and see what happens. But please, if you think of anything else, say it.

  • Oradv10.dll file is not placed in ORACLE_HOME\bin folder in windows

    Hello,
    I want to apply patch on my Oracle database 10g release 2 (10.2.0.1) and upgrade to 10.2.0.5.
    but i could not find database vault file in bin folder.
    can anyone guide what is the issue behind this !!??
    Please help me to sove this issue.
    Thanks in advance.
    Pradip Patel

    Hello,
    I have installed fresh Oracle 10g R2 (10.2.0.1) on my windows server 2003 platform.
    after this i want to apply patch (10.2.0.5) on this.
    before apply the patch we have to disable database vault but when i fire below query in my database to check my vault is enable or disable:
    SQL> SELECT * FROM V$OPTION WHERE PARAMETER = 'Oracle Database Vault';
    no rows selected
    i got this result.
    and even database vault file named oradv10.dll is also not in ORACLE_HOME\bin folder.
    so i want to know that when i installed my fresh oracle database at that time database vault utility install or i have to install manually after this.
    Guide me.
    Pradip Patel

  • "Hot Folder to FTP" script review please

    I'm trying to make a folder on my Mac that is a "Hot Folder." I want this folder to have an action/script that as soon as it sees a new file added it will open Fetch and upload via mirror to an FTP folder.
    I was able to make the Fetch portion of the script without issue, but making the folder "Hot" is a bit more difficult for me. I tried to use some script from the sample script "add - new item alert" but have been unsuccessful. I'm hoping some of you Applescript pros can review this and tell me how to correct. Or perhaps you know of a better way to make this work with automator.
    SCRIPT:
    on adding folder items to this_folder after receiving added_items
    try
    tell application "Finder"
    --get the name of the folder
    set the folder_name to the name of this_folder
    end tell
    -- find out how many new items have been placed in the folder
    set the item_count to the number of items in the added_items
    --create the alert string
    if the item_count is greater than 1 then
    tell application "Fetch"
    activate
    make new transfer window at beginning with properties {hostname:"ftp.hostname.here", username:"myusername", password:"mypassword", initial folder:"/pub/pao/images/"}
    mirror alias "Macintosh HD:Users:Bill:Desktop:test:" to url "ftp://myusername:@ftp.hostname.here/pub/pao/images/" format Automatic without delete strays
    end tell
    end if
    end try
    end adding folder items to
    Thank you all!

    Well, the most obvious problem is:
    if the item_count is greater than 1 then
    If you drop a single file into the folder, nothing will happen. That's because item_count will be 1, not greater than 1.
    If you don't care about how many files were dropped (because Transmit's mirror function will just synchronize the differences, then omit this line altogether - the script won't fire unless at least one file was added.

  • BPM: send 2 different files to same folder and then call RFC

    Hi Gurus,
    I need the design of this BPM:
    2 files are pulled from an FTP site, and both placed in an SAP folder (no mapping required). Once both files are placed, then I will need to call an RFC.
    I think in BPM for this:
    2 receiver steps (for both files) --> 2 sender steps (for both files) --> 1 transformation (for RFC mapping) --> 1 sender (for RFC)
    Am I ok with this?
    The only concern is that as the first receiver step starts the process, then for a mandatory reason I don't know I need a correlation on the second. Can I avoid this? how?

    Good idea with the dummy correlation.
    Does anyone know if I can use only 1 sender CC and get both files and then call the RFC only once?

  • Create folder in FTP site

    Hello,
    I have an FTP site that is used in conjunction with one of my processes. I would like to be able to check if a particular folder already exists in the FTP site, and if it doesn't create one. I have been able to do this within the regular file system (using the file utilities components Is Directory and Make Directory), but am having trouble setting this up in an FTP site. I have been trying to use those same components used for the file utilities, but can't seem to make it happen. Is it possible, and how should I go about doing this? Thank you ahead of time for any assistance.

    Kendy,
    Yes I am able to perform this task in the file system without any problems (creating network folders on shared network drives). I would like to be able to do the same with an FTP server. Aside from using an FTP server (uploading and downloading), I guess I'm lacking knowledge of how the back end of an FTP server works (I haven't had much luck in my google searches on the topic either). Should their be an accompanying file system location for an FTP site, or is FTP something that is set up on its own, seperate from a file system? If there is an accompanying file system location for an FTP server, then I can use the File Utility components to search for the folder, and create it if it doesn't already exist. I have tried doing this with the FTP site URL but am unable to get the MakeDir to work in this regard. I have also tried using the Put component from the FTP utilities. Placing a txt file in a folder that doesn't exist on my FTP server in hopes that it would create the directory, but this does not work either. I can Put the file in folders that already exist on the FTP site, but cannot automatically add these folders through a workflow.

  • Batch processing saves files in wrong folder.

    I ran into a problem the other day, and I believe an item should be added to the Process Multiple Files window, or perhaps it's a bug that should be squashed.
    I have a folder with many subfolders in it, all full of jpegs. I wanted to use the Process Multiple Files function to convert the jpegs into png files and have the png files placed into the same folder as the jpeg it originated from.
    I have the Destination set to Same as Source, but instead of placing the files into the subfolders, all the images go directly into the parent folder. It was much more time-consuming to try to sort them out than to start over and process each folder individually. I should be able to leave the computer unattended and have the files saved into the proper folders; Instead I had to stay close so I could change the Source folder every few minutes.
    I see no reason why there isn't an option to place the converted files into their original folder. Isn't that what the Same as Source setting is supposed to do?

    Sure, if you owned all of those files and were doing it strictly for yourself you could certainly write a plugin to Acrobat (in C/C++) that could do some/all of the things you asked for.

  • Script to search all files in specified folder for multiple string text values listed in a source file and output each match to one single results txt file

    I have been searching high and low for this one.  I have a vbscript that can successfully perform the function if one file is listed.  It does a Wscript.echo on the results and if I run this via command using cscript, I can output to a text file
    that way.  However, I cannot seem to get it to work properly if I want it to search ALL the files in the folder.  At one point, I was able to have it create the output file and appear as if it worked, but it never showed any results when the script
    was executed and folder was scanned.  So I am going back to the drawing board and starting from the beginning.
    I also have a txt file that contains the list of string text entries I would like it to search for.  Just for testing, I placed 4 lines of sample text and one single matching text in various target files and nothing comes back.  The current script
    I use for each file has been executed with a few hundred string text lines I want it to search against to well over one thousand.  It might take awhile, but it works every time. The purpose is to let this run against various log files in a folder and
    let it search.  There is no deleting, moving, changing of either the target folder/files to run against, nor of the file that contains the strings to search for.  It is a search (read) only function, going thru the entire contents of the folder and
    when done, performs the loop function and onto the next file to repeat the process until all files are searched.  When completed, instead of running a cscript to execute the script and outputting the results to text, I am trying to create that as part
    of the overall script.  Saving yet another step for me to do.
    My current script is set to append to the same results file and will echo [name of file I am searching]:  No errors found.  Otherwise, the
    output shows the filename and the string text that matched.  Because the results append to it, I can only run the script against each file separately or create individual output names.  I would rather not do that if I could include it all in one.
     This would also free me from babysitting it and running each file script separately upon the other's completion.  I can continue with my job and come back later and view the completed report all in one.  So
    if I could perform this on an entire folder, then I would want the entries to include the filename, the line number that the match occurred on in that file and the string text that was matched (each occurrence).  I don't want the entire line to be listed
    where the error was, just the match itself.
    Example:  (In the event this doesn't display correctly below, each match, it's corresponding filename and line number all go together on the same line.  It somehow posted the example jumbled when I listed it) 
    File1.txt Line 54 
    Job terminated unexpectedly
     File1.txt Line 58 Process not completed
    File1.txt
    Line 101 User input not provided
    File1.txt
    Line 105  Process not completed
    File2.txt
    No errors found
    File3.txt
    Line 35 No tape media found
    File3.txt
    Line 156 Bad surface media
    File3.txt Line 188
    Process terminated
    Those are just random fake examples for this post.
    This allows me to perform analysis on a set of files for various projects I am doing.  Later on, when the entire search is completed, I can go back to the results file and look and see what files had items I wish to follow up on.  Therefore, the
    line number that each match was found on will allow me to see the big picture of what was going on when the entry was logged.
    I actually import the results file into a spreadsheet, where further information is stored regarding each individual text string I am using.  Very useful.
    If you know how I can successfully achieve this in one script, please share.  I have seen plenty of posts out there where people have requested all different aspects of it, but I have yet to see it all put together in one and work successfully.
    Thanks for helping.

    I'm sorry.  I was so consumed in locating the issue that I completely overlooked posting what exactly I was needing  help with.   I did have one created, but I came across one that seemed more organized than what I originally created.  Later
    on I would learn that I had an error in log location on my original script and therefore thought it wasn't working properly.  Now that I am thinking that I am pretty close to achieving what I want with this one, I am just going to stick with it.
    However, I could still use help on it.  I am not sure what I did not set correctly or perhaps overlooking as a typing error that my very last line of this throws an "Expected Statement" error.  If I end with End, then it still gives same
    results.
    So to give credit where I located this:
    http://vbscriptwmi.uw.hu/ch12lev1sec7.html
    I then adjusted it for what I was doing.
    What this does does is it searches thru log files in a directory you specify when prompted.  It looks for words that are contained in another file; objFile2, and outputs the results of all matching words in each of those log files to another file:  errors.log
    Once all files are scanned to the end, the objects are closed and then a message is echoed letting you know (whether there errors found or not), so you know the script has been completed.
    What I had hoped to achieve was an output to the errors.log (when matches were found) the file name, the line number that match was located on in that file and what was the actual string text (not the whole line) that matched.  That way, I can go directly
    to each instance for particular events if further analysis is needed later on.
    So I could use help on what statement should I be closing this with.  What event, events or error did I overlook that I keep getting prompted for that.  Any help would be appreciated.
    Option Explicit
    'Prompt user for the log file they want to search
    Dim varLogPath
    varLogPath = InputBox("Enter the complete path of the logs folder.")
    'Create filesystem object
    Dim oFSO
    Set oFSO = WScript.CreateObject("Scripting.FileSystemObject")
    'Creates the output file that will contain errors found during search
    Dim oTSOut
    Set oTSOut = oFSO.CreateTextFile("c:\Scripts\errors.log")
    'Loop through each file in the folder
    Dim oFile, varFoundNone
    VarFoundNone = True
    For Each oFile In oFSO.GetFolder(varLogPath).Files
        'Verifies files scanned are log files
        If LCase(Right(oFile.Name,3)) = "log" Then
            'Open the log file
            Dim oTS
            oTS = oFSO.OpenTextFile(oFile.Path)
            'Sets the file log that contains error list to look for
            Dim oFile2
            Set oFile2 = oFSO.OpenTextFile("c:\Scripts\livescan\lserrors.txt", ForReading)
            'Begin reading each line of the textstream
            Dim varLine
            Do Until oTS.AtEndOfStream
                varLine = oTS.ReadLine
                Set objRegEx = CreateObject("VBScript.RegExp")
                objRegEx.Global = True  
                Dim colMatches, strName, strText
                Do Until oErrors.AtEndOfStream
                    strName = oFile2.ReadLine
                    objRegEx.Pattern = ".{0,}" & strName & ".{0,}\n"
                    Set colMatches = objRegEx.Execute(varLine)  
                    If colMatches.Count > 0 Then
                        For Each strMatch in colMatches 
                            strText = strText & strMatch.Value
                            WScript.Echo "Errors found."
                            oTSOut.WriteLine oFile.Name, varLine.Line, varLine
                            VarFoundNone = False
                        Next
                    End If
                Loop
                oTS.Close
                oFile2.Close
                oTSOut.Close
                Exit Do
                If VarFoundNone = True Then
                    WScript.Echo "No errors found."
                Else
                    WScript.Echo "Errors found.  Check logfile for more info."
                End If
        End if

  • How to publish to an FTB server in iWeb 2 using the File ➙ Publish to Folder option??

    I was just given the following advice regarding publishing to an FTP other than MobileMe. 
    Web 08 does not have that feature (drop down menu to publish from "site" icon).  You will need to upgrade to iWeb 3 in iLife 11 in order to get that feature.  You can get iLife 11 at the online Apple Store while supplies last since iWeb (and iDVD) have been discontinued by Apple
    To pubish to an FTB server in iWeb 2 use the File ➙ Publish to Folder menu option and then use a 3rd party FTP client like Cyberduck to upload the site files.
    Follon-on question, can anyone provide more details on how to do exactly what was suggested?  I toyed with it and can only get it to publish to a folder on my desktop, but not to an external FTP.  (I have already purchased a web-host package, just need to publish to it!)

    Okay.  When you publish your site from iWeb to a local folder what you will get is one site folder - this site folder will have the same name as you gave your site in iWeb and one separate index.html file.
    Your site folder contains an index.html file as well as the separate index.html file.  You NEED both.
    What you need to do is firstly using Cyberduck or whatever, upload your site folder to your host into whatever folder you need to upload to on the server - could be 'public_html', 'htdocs' or whatever - this is your root folder.
    You then need to upload your separate index.html file to your server too, but this index file needs to sit outside your site folder because it needs to point in towards the index.html file that is in your site folder - this is the first page of your site.
    You don't delete or duplicate any index files - iWeb produces the two index files that you need when you publish to a local folder - one index file in the site folder itself and one separate index file that sits outside the site folder and points into the first page of your site. 
    Also, remember to call the first page of your site something like Home or Welcome, but DO NOT name it index.
    By the looks of things here you have not uploaded your index files correctly.
    What I would suggest that you do is start over - so open Cyberduck and connect to your server and go and delete your site folder and your other index file if it is still there.
    Go back to iWeb and publish to a local folder again and notice that you have both your site folder and separate index.html file.
    Now go and open Cyberduck again and connect to your server and note where you need to upload your files to.
    Now go and upload your Site Folder to your server and once this has finished go back and upload your separate index.html file, but this needs to sit outside your site folder.  If you do this, then your site should display okay - as long as your other index file is pointing into to the first page of your site it should display correctly.

  • File to File scenario using Transport Protocol FTP  Problem

    Hi,
    my scenario is a file to file scenario using Transport Protocol FTP
    there are 3 systems involved
    a. computer 1 ( My system-source)
    b. computer 2 (XI server)
    c. computer 3 (Target system)
    I want XI to pick file from computer 1 and post it to computer 3
    I am logging on to XI server from computer 1(thro SAP GUI),
    <u><b>Sender communication  channel :</b></u>
    Transport protocol:FTP
    Messsage protocol: file
    <u><b>In FTP connection Parameters:</b></u>
    Server: computer 1 IP address
    port:21
    User name and PW---> I have given computer 1 Username and password.
    Connection mode: permanently
    Transfer mode: Binary
    Folder: C:\ftproot\output
    filename : given
    <u><b>In Receiver Communication Channel</b></u>
    Transport protocol:FTP
    Message protocol: file
    <u><b>In FTP connection Parameters:</b></u>
    Server: computer 3 IP address
    port:21
    User name and PW---> I have given computer 3 Username and password.
    Connection mode: permanently
    Transfer mode: Binary
    Put File: Use Temporary File
    Folder:
    eccserver\saploc\tmp
    filename scheme: given
    When I activate the scenario file is not getting picked from the source
    In Adapter Framework: Message says up and running No message processing now
    How to check FTP server is up and running on computer 1 (source system)and Computer 2 (XI server)?
    What could be the problem ?
    Thanks
    dushanth

    Hi
    Consider that I dont have FTP installed on my computer. According to this blog
    /people/shabarish.vijayakumar/blog/2006/08/01/along-came-a-file-adapter-mr-ftp-and-rest-of-the-gang
    I have configured.
    In sender comm channel I have given Ipaddress of computer 1 (which has a file to be picked)
    In Receiver Comm channel I have given IP address of computer 3 (in which file to be posted)
    and computer 2 is the XI server
    Computer 1 has FTP installed
    1. XI server should have FTP installed or not ? IF yes is it FTP client  or FTP server   or Guild FTP (according to the blog is enough)
    2. Computer 3 should have FTP installed or not ?
    Please help me I am really confused.
    Thanks
    dushanth

  • Arranging files in a Folder

    I want to be able to drag and drop files in a folder how I want them placed and not (as my Mac wants) by either Name or Type or Date Created. I just want to arrange an order and have it stay that way (not unlike a playlist).

    When I do as you describe I never get the option to "Keep arranged by" or anything pertaining to "This window only" or "All windows"
    From my Finder/Show View Options I see this:
    A box to "Always open in list view"
    A choice of Icon size and Text size
    Show columns:
    Date modified
    Date created
    Size
    Kind
    Version
    Comments
    Label
    The three more boxes asking:
    Use relative dates
    Calculate all sizes
    Show icon previews
    and at the end it asks:
    Use as defaults
    And that's all I get the chance to do.

  • File selection sequence in the FTP connection for File Sender Adapter

    Hi,
    I have a file to Proxy scenario using FTP connection parameters.
    If there are multiple files in the sender folder, XI picks up the files randomly with no processing sequence.
    I want XI to pick up the files based on the date time stamp meaning the  oldest file created in the folder should be processes first and rest all in sequence there after.
    I know processing sequence can be set for NFS connection but not for FTP .
    Please suggest if there's any way to make this work.
    Thanks in advance.
    Thanks and Regards,
    Amit Bhagwat.
    Edited by: Amit Bhagwat on Nov 4, 2009 5:17 AM

    Hi
    For the Transport Protocol "File Transfer Protocol (FTP)" files are always processed in ascending alphabetical order
    If you want the file to be processed in sequence then you can use Quality of Service EOIO in the sender adapter.
    The files are processed in the sequence they are picked up.
    otherwise use BPM for File Sequencing..
    Refer the following Threads
    FTP Sender Adapter - Processing Sequence
    Processing Sequence issue of FTP protocol
    Regards
    Abhijit
    Edited by: Abhijit Bolakhe on Nov 4, 2009 10:32 AM

  • Archiving File on Shared Folder in Linux using java code

    Hi All,
    I have a requirement wherein I have to ftp a file (Feed.txt) from windows FTP server to Linux machine1 and archive the same file (with timestamp suffixed on file name like Feed.txt_22April) on Linux Machine2. I am
    trying to achieve this through java code. I am able to ftp the file(Feed.txt) from windows ftp server to Linux machine1 /opt/ftproot directory and archiving the same file under /opt/ftproot/archive directory of Linux
    Machine1 with timestamp suffixed on file name.
    My archiving requirement is still not achieved. So, for that I created a shared folder “/temp/shared” on Linux Machine2 and mounted the /temp/shared folder of Linux Machine2 on /opt/ftproot/archive folder of
    Linux Machine1 using following command:
    # mount LinuxMachine2: /temp/shared /opt/ftproot/archive
    Note: I have given full permission on both the folders.
    Logically, archiving the Feed.txt with timestamp in it name under /opt/ftproot/archive folder should create the file in /temp/shared folder of Linux Machine2. But instead of archiving the file on
    /opt/ftproot/archive folder, it archive the file on /opt/ftproot folder.
    In my java code, I have specified copyDir as “/opt/ftproot” and archiveDir as /opt/ftproot/archive”.
    The code is being run from Linux Machine1 as a schedule task.
    Please help.
    PFB the code snippet:
    package com.ftp;
    import com.thortech.xl.scheduler.tasks.SchedulerBaseTask;
    import org.apache.commons.net.ftp.*;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.text.DateFormat;
    import java.text.SimpleDateFormat;
    import java.util.Calendar;
    import java.util.Date;
    public class FTPService extends SchedulerBaseTask {
         private static String targetDir="";
         private static String archiveDir="";
    public void init() {
    public void execute() {
    try {
    String server = "Machine1
    String username = "username";
    String password = "password";
    String sourceDir = "C:\\Inetpub\\ftproot\\temp.txt";
    //String archiveDir = "/home/ftproot1";
    targetDir = getAttribute("Target Directory");
    FTPClient ftp = new FTPClient();
    * Connect to the server
    ftp.connect(server);
    ftp.login(username, password);
    System.out.println("Connected to " + server + ".");
    String[] names = ftp.listNames();
    for (String name : names) {
    System.out.println("Name = " + name);
    * Get all file names that are present in the current working directory
    FTPFile[] files = ftp.listFiles();
    String fileName = "";
    for (int i = 0; i < files.length; i++) {
    if (files.isFile()) {
    System.out.println("\t" + files[i].getName());
    File file = new File(targetDir + File.separator +
    files[i].getName());
    FileOutputStream fos = new FileOutputStream(file);
    * Copy the file to target system
    ftp.retrieveFile(files[i].getName(), fos);
    fos.close();
    fileName = files[i].getName();
    ftp.logout();
    ftp.disconnect();
    System.out.println("End of FTP....");
    System.out.println("Calling fileCopy()");
    System.out.println("Target Directory"+targetDir);
    fileCopy(fileName,targetDir);
    } catch (Exception e) {
    e.printStackTrace();
    public static String getDate() {
    String sdate = "";
    try {
         System.out.println("Inside getDate()");
    Calendar date = Calendar.getInstance();
    SimpleDateFormat formatter = new SimpleDateFormat(
    "yyyy-MM-dd HH:mm:ss.0");
    sdate = formatter.format(date.getTime());
    } catch (Exception e) {
    return sdate;
    public void moveFile(String t) {
         try{
         System.out.println("inside moveFile");
    System.out.println("Moving Files");
    File fro = new File(t);
    archiveDir = getAttribute("Archive Directory");
    System.out.println("Archiving Directory"+archiveDir);
    File to = new File(archiveDir);
    boolean archived = fro.renameTo(new File(to, fro.getName()));
    if (archived) {
    System.out.println("FileArchived");
              /*String cmd="mv" +" "+t +" "+ "/home/ftproot/archive";
              System.out.println("Archive Directory"+archiveDir);
              System.out.println("Move Command"+cmd);
              Process SshProc =      (Runtime.getRuntime()).exec(cmd);
    } catch (Exception e) {
    e.printStackTrace();
    public void fileCopy(String filename,String Directory) {
         try{
         //String ifile="/home/ftproot/sunny.txt";
              String ifile=targetDir+"/"+filename;
         String ofile=ifile+"_"+getDate();
         File f1 = new File(ifile);
         File f2 = new File(ofile);
         InputStream in = new FileInputStream(f1);
         //For Append the file.
    //      OutputStream out = new FileOutputStream(f2,true);
         //For Overwrite the file.
         OutputStream out = new FileOutputStream(f2);
         byte[] buf = new byte[1024];
         int len;
         while ((len = in.read(buf)) > 0){
         out.write(buf, 0, len);
         in.close();
         out.close();
         System.out.println("File copied.");
         moveFile(ofile);
         }catch(Exception e)
         System.out.println("File copied."+e);
    Cheers,
    Sunny

    sunnyajmera wrote:
    Please help.If it was me....
    - You are connecting to a ftp server. I am guessing you didn't write that.
    - Get a flexible ftp client, there are many but make sure it shows you the ftp result codes.
    - Figure out how and if the ftp server will do what you want.
    If it does do what you want then ftp client will let you do the same thing.
    If that ftp server doesn't allow you to do it then you must do one of the following
    - Find a different server
    - Change the requirements
    - Find a way to impose the requirements using a tool in addition to ftp like some command executed through telnet.

Maybe you are looking for

  • Attaching a Mail message to an iCal event?

    When I put a new event on a calendar day, I like to drag the relevant email to that event. And it works. The problem is with the dragging process. it's very awkward. When constructing the event it offers options to add a url or a file. But the email

  • Problems burning a workout video for it to work on my dvd player? help

    I've just purchased ripped in 30 days by Jillian Michaels and I thought that I could burn it to a dvd and then watch it my tv but its not working. Any suggestions?

  • Query regarding BT having incorrect info

    Hi there Im currently a Sky broadband customer after moving properties im intrested in getting Infinity - when I had my original line activated the BT engineer confirmed that the cabinet im connected to does indeed have fibre hardware - however every

  • Making an InputSource from a String

    I need to parse some XML that is in a string. I have created a document object to parse the xml, but I need to get it in the format of an InputSource. Here is the code that I have written. I am getting an error that says: "InputSource not found in ty

  • IPad 2 not receiving emails

    I have recently purchased an iPad 2. I already own a mac computer and owned an original iPad. With my originally iPad i recieved all emails i received on my computer, but with my new iPad 2 I only get some emails. They will go to my computer but not