Access/download file from server.

have a problem. When I am trying to save/open a file from server(secure) which uses HTTPS, its displaying error message:
Internet Explorer cannot download ...File_name.doc from Server_name.
Internet Explorer was not able to open this Internet site. The requested site is either unavailable or cannot be found. Please try again later.
My code is below. Please help me out.
Its working with my localhost(http) and with Firefix browser. Its something to do with http and IE 6.
<java>
if (!request.getScheme().equals("https"))
response.setHeader("Pragma", "no-cache");
     String fileName=request.getParameter("instruction");
     //filename = filename.replaceAll( "\\W*", "" ) ;
     String DirName = request.getParameter("directory");
     String value = (DirName+"/"+fileName);
               File f = new File (value);
               response.setContentType("application/msword");
               //set the header and also the Name by which user will be prompted to save
               response.setHeader("Content-disposition", "attachment; filename=" + fileName);
               InputStream in = new FileInputStream(f);
               out.clearBuffer();          
               int bit = 256;
               int i = 0;
               try {
                    while ((bit) >= 0) {
                         bit = in.read();
                         out.write(bit);
               } catch (IOException ioe) {
                    ioe.printStackTrace(System.out);
               out.flush();
               out.close();
               in.close();     
</java>

HI,
To avoid redirection, Safari users are having good luck with Open DNS Free / Basic
Carolyn

Similar Messages

  • Downloading File from server

    I have written more or less same code like following
    to send file from server to browser in other web applications, where browser displays Save As dialog box
    to the user, but the same code doesn't work with portal.
    following code part of a page flow
    <pre>
    * @jpf:action
    * @jpf:forward name="success" path="index.jsp"
    protected Forward doUploadFile()
    HttpServletResponse res = this.getResponse();
    res.setContentType("application/x-download");
    String filename="C:\\somefile.pdf";
    File file = new File(filename);
    res.setContentLength((int)file.length());
    res.setHeader("Content-Disposition", "attachment;
    filename=" +filename);
    // Send the file.
    InputStream in=null;
    OutputStream out=null;
    try
    out = res.getOutputStream( );
    in = new BufferedInputStream(
    new FileInputStream(filename));
    byte[  ] buf = new byte[4 * 1024]; // 4K buffer
    int bytesRead;
    while ((bytesRead = in.read(buf)) != -1)
    out.write(buf, 0, bytesRead);
    finally
    if (in != null) in.close();
    if (out!= null) out.close();
    return new Forward("success");
    </pre>
    following is the JSP code to trigger the action of file
    download.
    <pre>
    <netui:form action="doUploadFile">
    <netui:button type="submit" value="Upload File" />
    </netui:form>
    </pre>
    Any clue ?

    Hi,
    Im having exactly the same problem. Did you find a way to do this.
    Thanks Chris

  • Code to download file from server

    Hi
    I need some code to download file from a server to a local machine.
    Can anybody help me, PLEASE
    Yohan Shikari

    If i try this :
    try
    //          path where the file is stord
    //          String idocPath = config.getServletContext().getInitParameter("idocPath");
              String idocPath = "C:/";
              String fileName = "http://194.98.51.253/utimaco.cer";
              String filePath = idocPath + "\\" + fileName;
              response.setContentType("APPLICATION/OCTET-STREAM");
              String disHeader = "Attachment;Filename=" + fileName ;
              response.setHeader("Content-Disposition", disHeader);
              File file = new File(filePath);
              FileInputStream fileInputStream = new FileInputStream(file);
              int i;
              while ((i=fileInputStream.read())!=-1)
              response.getOutputStream().write(i);
              response.getOutputStream().flush();
              response.getOutputStream().close();
              fileInputStream.close();
              }catch(Exception e)
              e.printStackTrace();
    I don't understand the "type variable" of response !!!
    Thomas

  • How to download file from server to client's local ??

    How to download a file from the server to the client's local machine in a particular folder without users intervention ie. 'Save As" prompt of the browser should be avoided and if the client clicks on "Download" button, the file should get automaticaly downloaded to say, "c:/reports/' on his/her local machine. This is for Java based web appliaction.

    http://jguru.com/faq/view.jsp?EID=10646

  • Download file from server to Mobile Device

    Hello everyone,
    I would like to know firstly if downloading a file from a server to the Mobile device is possible or not. Secondly, if it is then is there a working example (code) I can use.
    What I need is to simply download a text (.txt) file, nothing fancy :-)
    Thanks,
    TADA

    Hi,
    First of all your mobile device has to support JSR75 (PDA Optional Package for J2ME = File connection & PIM).
    Use following link to read a very useful article at SDN, about this API.
    http://developers.sun.com/techtopics/mobility/apis/ttips/fileconnection/
    There is also the sample code located, you are looking for.
    bye,
    Asghar

  • FTP error on downloading files from server

    I haven't changed my server settings in quite awhile, but
    some time ago, I started getting "FTP errors -- could not get file
    xxx.htm", and no further explanation.
    I am able to see all my files on the server, and am able to
    upload saved files to the server, as well as copy files from my
    local hard drive and upload them to the server. The only I can't do
    is get any files.
    I wrote to my ISP's tech support to check their logs, and all
    they saw was that all was well on their end. No permissions issues
    or errors reported in their logs.
    They asked if I had Passive mode checked -- I did. They
    suggested I disable my Firewall -- I don't have one. And that I try
    another FTP program. I tried FTP itself in Terminal, and my old
    version of GoLive 9. Both were able to get any file I requested,
    using the same connection settings and machine.
    So they're stumped.
    What am I doing wrong?

    Hi, Alan--
    My ISP checked their logs and found no permissions problems
    with any of the files I was attempting to download. I also checked
    the DW FTP log (Site-->Advanced-->FTP Log), and I am the only
    user who has any permissions on any file or directory, and I am
    logged in as my user.
    The log shows no attempt at a download being made at all, but
    only a LIST command:
    > CWD /usr/www/users/grndlvl/commerce/gl
    < 250 "/usr/www/users/grndlvl/commerce/gl" is new cwd.
    > PASV
    < 227 Entering Passive Mode (209,68,2,99,210,107)
    > TYPE A
    < 200 Type okay.
    > LIST
    < 150 Data connection accepted from 97.93.92.248:56921;
    transfer starting.
    < -rw-r--r-- 1 grndlvl users 74417 May 21 2008
    CSScriptLib.js
    < -rwxr-xr-x 1 grndlvl users 3242 May 21 2008 ccval.php
    < -rwxr-xr-x 1 grndlvl users 811 Jul 14 2008 error.php
    < -rw-r--r-- 1 grndlvl users 446 May 21 2008 font_set.css
    < -rwxr-xr-x 1 grndlvl users 2812 Jun 15 2008
    formContent.php
    < drwxr-xr-x 2 grndlvl users 2560 May 21 2008 images
    < drwxr-xr-x 2 grndlvl users 512 May 21 2008 includes
    < -rw-r--r-- 1 grndlvl users 24656 Mar 7 18:23
    index.shtml
    < -rw-r--r-- 1 grndlvl users 24685 May 25 2008
    indexf.shtml
    < -rwxr-xr-x 1 grndlvl users 8113 Mar 7 17:57 process.php
    < -rwxr-xr-x 1 grndlvl users 8109 Jun 13 2008
    processup.php
    < -rwxr-xr-x 1 grndlvl users 7976 May 22 2008
    processupf.php
    < -rwxr-xr-x 1 grndlvl users 5230 Mar 7 18:50 receipt.php
    < -rwxr-xr-x 1 grndlvl users 11904 Jun 28 2008
    receiptgl.php
    < drwxr-xr-x 2 grndlvl users 512 May 21 2008 ssi
    < -rwxr-xr-x 1 grndlvl users 368 May 21 2008 sysinfo.php
    < drwxr-xr-x 2 grndlvl users 512 May 21 2008 test
    < -rwxr-xr-x 1 grndlvl users 1557 May 21 2008 testcc.php
    < -rwxr-xr-x 1 grndlvl users 378 May 21 2008 transact.pl
    < 226 Listing completed.
    And here is the error log:
    Started: 3/8/09 4:09 AM
    /usr/home/grndlvl/public_html/commerce/gl/ccval.php - error
    occurred - An FTP error occurred - cannot get ccval.php.
    File activity incomplete. 1 file(s) or folder(s) were not
    completed.
    Files with errors: 1
    /usr/home/grndlvl/public_html/commerce/gl/ccval.php
    Finished: 3/8/09 4:09 AM
    This is happening for every file and every directory on my
    site.
    All My Best,
    Jeffrey

  • Issues in Download File from Server to PC

    Hi Experts,
    i am havin requirement to download a File and show it to user in open/Sava dialog box.
    i have tried both way to achieve this.
    1)  cl_wd_runtime_services 2 File Download Elements
    here is coding for cl_wd_runtime_services
      CONCATENATE 'C:\temp\'
                         stru_ctx_resume-cv_language
                         stru_ctx_resume-cv_type
                         stru_ctx_resume-oprn_role
                         lv_version
                          '.pdf' INTO lv_filename.
            lv_filetype = 'application/pdf'.
            lr_conv_out = cl_abap_conv_out_ce=>create( encoding = 'UTF-8' ).
    Showing Downloaded File to new Window.
            cl_wd_runtime_services=>attach_file_to_response(
              i_filename  = lv_filename
              i_content   = lv_filecontent " Its file Byte Array
              i_mime_type = lv_filetype
              i_in_new_window = abap_false
              i_inplace       = abap_false ).
    Problem Statement: Filedownload is working perfect, the only prolem is that IE give warning message before download, i want to get rid of this warning message so i opted for File Download UI Element.
    2) File Dowload Element:
    i have a file download element in a table collumn, this table is mapped to a node Called CTX_Resume, file download element's data property is mapped to attribute called file_content of type xSTring, this attribute is in node called data which is child node of CTX_Resume.(1:N, Lead Selection True, Singleton True)
    so in summary
    CTX_Resume(Node): Mapped to table
        File_DATA(Sub Node of CTX_Resume): It has Supply methodName: Sup_File_Data
              File_Content(Type Xstring) Mapped to Data property of Filedownload
    Codding at Supply Method is
    METHOD sup_file_data .
    data declaration
      DATA:
        stru_file_data            TYPE wd_this->element_file_data,
        stru_resume           TYPE wd_this->element_ctx_resume,
            lv_filecontent TYPE zall_empprof_file_content,      "#EC NEEDED
            lv_error_text TYPE zall_empprof_error_text,         "#EC NEEDED
    if wd_this->mv_first_time = abap_false.
      CALL METHOD parent_element->get_static_attributes
        IMPORTING
          static_attributes = stru_resume.
      if not stru_resume is INITIAL.
        MOVE stru_resume-cv_version TO lv_version.
      CALL METHOD wd_assist->download_cv
        EXPORTING
          im_doc_id       = stru_resume-doc_id
          im_doc_type     = 'pdf'
          im_doc_version  = stru_resume-cv_version
        IMPORTING
          ex_file_content = lv_filecontent " File Byte Array
          ex_error_text   = lv_error_text.
      IF lv_error_text IS INITIAL.
        move lv_filecontent to stru_file_data-file_content.
      ENDIF.
    else.
      wd_this->mv_first_time = abap_false.
    endif.
      node->bind_structure(
        new_item =  stru_file_data
        set_initial_elements = abap_true ).
    ENDMETHOD.
    Problem Statement: this works perfect only at first time as i cant controll the triggering of Supply method, to get rid of this i want whenever user clicks on File Download Link, it must trigger supply method.
    My table doesnt have selections properites = none.
    hope i have given sufficiant information about the problem,
    please help me....
    Regards
    Manish.
    Edited by: Manish Vijay on Jul 3, 2009 2:28 PM
    Edited by: Manish Vijay on Jul 3, 2009 2:34 PM

    It depends on your browser mime type setting.
    If you donload a doc file for example and the client's browser is set as to open doc files automatically with word application you will not get the save file dialog box.
    Its all dependent on the client machine setting and not on forms.

  • Air download files from server

    I have an Air app that should display a DataGrid with a list of files that can be downloaded from my web server. It works perfect as a Flex program. I get 2 errors that I list at the bottom. I have a downloadFile.as file in a com folder
    <mx:Script>
    <![CDATA[
    import mx.collections.ArrayCollection; 
    import mx.rpc.events.ResultEvent; 
    import mx.controls.Alert; 
    import mx.events.ListEvent; 
    Bindable] public var directoryDS:ArrayCollection; 
    Bindable] public var serviceURL:String; 
    Bindable] public var fileIndex:Number;  
    public function initApp():void{
    serviceURL =
    "http://www.youngsmarket.com/directory.cfm"; //Set the URL to the httpservice
    directoryDS =
    new ArrayCollection([]); // This is where the results of the httpservice will end up.
    fileIndex = -1;
    directory_srv.send();
    // Taking the data returned from the httpservice and creating FileDownload objects to populate the directoryDS array collection.
    private function setDataSource(evtObj:Object):void
    var fileDL:DownloadFile; 
    var collection:ArrayCollection = evtObj.directory.file as ArrayCollection; // pass httpservice result into a local scope
    var i:int; 
    //loop over results and create a new DownloadFile object and add it to the directoryDS ArrayCollection
    for (i=0;i < collection.length; i++){
    fileDL =
    new DownloadFile();fileDL._file = collection.getItemAt(i).name;
    fileDL._url =
    "http://www.youngsmarket.com/myFiles/"; // Change this to match your Files directory path.
    fileDL._size = collection.getItemAt(i).size;
    directoryDS.addItem(fileDL);
    ]]>
    </mx:Script>
    <mx:HTTPService  id="directory_srv" url="{serviceURL}" result="setDataSource(event.result)"/>
    <mx:DataGrid  dataProvider="{directoryDS}" id="filesDG" doubleClickEnabled="true" itemDoubleClick="downloadFile()" change="setFileIndex(event.target.selectedIndex);"width="
    100%" height="100%" borderStyle="none" themeColor="#73B9B9">
     <mx:columns>
     <mx:DataGridColumn dataField="_file" headerText="File" minWidth="150" />
     <mx:DataGridColumn dataField="_size" headerText="Size" minWidth="100" />
     </mx:columns>
     </mx:DataGrid>
    Error on this line:   var fileDL:DownloadFile;
    the error is:   Type not found or is not compile time constant: DownloadFile
    the next error is this line:    fileDL = new DownloadFile();
    the error is:     call to a possibly undefined method DownloadFile

    hi,
    where is the import statement for the downloadfile class.....
    David.

  • Download file from server

    Hi All,
    I am creating & storing some PDF files in a folder in the server. I want to give a link in a JSP where the user can download the files fromt he server where it is stored. There are so many ways, please some one enlighten me on this; about which is the best way to do it.. the user should be able to see the dialogue box to save or print the document..
    Thanks a million in advance
    smallpost

    Hi All,
    I am creating & storing some PDF files in a folder
    in the server. I want to give a link in a JSP where
    the user can download the files fromt he server
    where it is stored. Just give the link.
    There are so many ways, please
    some one enlighten me on this; about which is the
    best way to do it.. Just give the link.
    the user should be able to see
    the dialogue box to save or print the document..Why a dialog? Those options (print and save) are available in the Acrobat Reader plug-in.

  • Download Files from Server to Client

    I have a flex application that sends data to a php page that
    then generates a pdf file and returns the name of that file to the
    application. All of that works fine. The problems start when I try
    to then download that file to the client.
    This is the Flex client code:
    <mx:Script>
    <![CDATA[
    import mx.collections.ArrayCollection;
    import mx.rpc.events.ResultEvent;
    [Bindable]
    private var pdfFiles:ArrayCollection;
    private function requestPDFHandler (event:ResultEvent):void
    if( event.result.Files == null ) { /* Table is empty */
    /*Do Nothing*/
    }else if( event.result.Files.File is ObjectProxy ) { /*
    Table has only one record */
    pdfFiles = new ArrayCollection( [event.result.Files.File] );
    }else { /* Table has many records */
    pdfFiles = event.result.Files.File as ArrayCollection;
    downloadPDF();
    private function getPDF():void {
    requestPDF.send();
    import flash.display.Sprite;
    import flash.events.*;
    import flash.net.FileReference;
    import flash.net.URLRequest;
    import flash.net.URLRequestMethod;
    private function downloadPDF():void {
    //trace (pdfFiles.list.getItemAt(0).FileName);
    var DOWNLOAD_URL:String = "
    http://" + dbLoc + "/PDF/tmp/" +
    pdfFiles.list.getItemAt(0).FileName;
    //trace(DOWNLOAD_URL);
    var fr:FileReference = new FileReference();
    var request:URLRequest = new URLRequest();
    request.url = DOWNLOAD_URL;
    //configureListeners(fr);
    fr.addEventListener(Event.CANCEL, cancelHandler);
    fr.download(request,"Product List.pdf");
    private function cancelHandler(event:Event):void {
    trace("cancelHandler: " + event);
    ]]>
    </mx:Script>
    <mx:HTTPService id="requestPDF" url="
    http://{dbLoc}/PDF/MakePDFDoc.php"
    method="POST" result="requestPDFHandler(event)">
    <mx:request xmlns="">
    <ProdGroupID>{cboProdGroup.selectedItem.ID}</ProdGroupID><CurrencyID>{cboCurrency.selecte dItem.ID}</CurrencyID>
    </mx:request>
    </mx:HTTPService>
    <mx:Button x="574" y="804" label="Save as PDF"
    width="144" height="34" fontFamily="Verdana" fontSize="12"
    cornerRadius="12" id="btnSavePDF" enabled="true"
    fillColors="[#33332d, #33332d]" fillAlphas="[1.0, 1.0]"
    color="#ffffff" textRollOverColor="#808080"
    textSelectedColor="#808080" borderColor="#000000"
    mouseUp="getPDF()"/>
    When the button is clicked it sends to the php page fine and
    recieves the name of the file. When it gets to
    "fr.download(request,"Product List.pdf");" in the downloadPDF
    function, the 'fr:FileReference' object gives me this error -
    "Error: Error #2037: Functions called in incorrect sequence, or
    earlier call was unsuccessful.". I don't understand what is causing
    the error. Any suggestions?

    Basically, you can try to:
    1. create a ServerSocket to listen to client request.
    2. once a request is received create a thread to handle that connection.
    3. find out what file does the client want.
    4. read the file into a byte array.
    5. flush the byte array back to the socket back to the client.
    6. once the client receive the content, start writing it to disk.
    You have to look into classes like ServerSocket, Socket, DataInputStream, DataOutputStream, FileInputStream, FileOutputStream, and etc.
    There are other ways to do it.
    Hope this helps.

  • Applet question, how to download resource files from server

    hi,
    i am new at applet world.
    i have an applet that reads some resource, data and configuration files. so i need to download these files from server to client. i did some resarch and could not find how to download files from server in an applet application.
    how can i do this task?
    thank you for your answers.

    You may want to distinguish between 'resources' and data/configuration files.
    'Resources' are non-class files that are part of your application, i.e without them the application would simply not work, just like class files.
    Those are typically images, sounds or resource bundles (GUI elements translated to different languages) that nobody except you, the developer, would touch (when releasing an upgrade or a patch).
    Those should just go into the applet jar or additional jars named in the applet tag.
    Data/configuration files, that may be changed by others than the developers, should be made available through HTTP, just like the applet jar itself. The applet will have (read) access to them using java.net.URLConnection.

  • Help required with downloading files from inside WEB-INF folder

    I am working on a web application and I have an upload script which uploads different files to a foler called 'uploads' . To stop users from accessing the folder content I have put it in the /WEB-INF/.
    In my JSP file, I used to link to the uploaded files like this before for users to download them :
    if(filesListIterator.hasNext()
    files = (FilesBean)filesListIterator.next();
    <tr><td><a target="_new" href="<%=files.getFileName()%>">"<%=files.getFileName()%></a></td></tr>
    }I need to know how to alter the above link to make it access/download files from the /WEB-INF/uploads/ while still restricting direct access to the files.
    Thanks
    Message was edited by:
    topiwal

    Anything under WEB-INF is not directly accessible via the browser/ client. You could try defining the JSP/ Servlet inside web.xml deployment descriptor and see if you can access the file from there.
    I think a better way to accomplish this would be to keep the file outside WEB-INF , and use other techniques to protect the folder that contains the file - for example password-protection, or defining a .htaccess file and serving a 403 Forbidden error.

  • [HELP] Download file from FTP server

    hi,
    I want to write a java program that can download and upload files from ftp server. Currently I only manage to upload a file to ftp server but i cant download file from ftp server. Here is the source code that only allow user to upload file. Anyone can give me some guidelines so that my program can download and also upload file? thx.
    import java.io.*;
    import java.net.*;
    public class FTPUpload {
    private static final int CTRLPORT = 21;
    private static Socket ctrlSocket;
    private static PrintWriter ctrlOutput;
    private static BufferedReader ctrlInput;
    private static byte[] localHostAddress;
    public final static String DIR = "C:\\zip\\";
    public static void main(String[] args) {
    try {
    String host = "192.168.1.1";
    String loginName = "testuser";
    String password = "password";
    String dirName = "/home/testuser";
    String fileName = "hello.zip";
    ctrlSocket = new Socket(host, CTRLPORT);
    localHostAddress = ctrlSocket.getLocalAddress().getAddress();
    ctrlOutput = new PrintWriter(ctrlSocket.getOutputStream());
    ctrlInput = new BufferedReader(new InputStreamReader(ctrlSocket.getInputStream()));
    ctrlOutput.println("USER " + loginName);
    ctrlOutput.flush();
    ctrlOutput.println("PASS " + password);
    ctrlOutput.flush();
    ctrlOutput.println("CWD " + dirName);
    ctrlOutput.flush();
    ctrlOutput.println("TYPE I");
    ctrlOutput.flush();
    FileInputStream fis = new FileInputStream(DIR + fileName);
    Socket dataSocket = dataConnection("STOR " + fileName);
    OutputStream outstr = dataSocket.getOutputStream();
    int n;
    byte[] buff = new byte[1024];
    while ((n = fis.read(buff)) > 0) {
    outstr.write(buff,0,n);
    dataSocket.close();
    fis.close();
    ctrlOutput.close();
    ctrlInput.close();
    ctrlSocket.close();
    }catch (Exception e) {
    e.printStackTrace();
    private static Socket dataConnection(String ctrlcmd)
    throws IOException,UnknownHostException {
    String cmd = "PORT ";
    ServerSocket serverDataSocket = new ServerSocket(0,1);
    for (int i=0;i<4;i++) {
    cmd = cmd + (localHostAddress[i] & 0xff) + ",";
    cmd = cmd + (((serverDataSocket.getLocalPort())/256) & 0xff)
    + ","
    + (serverDataSocket.getLocalPort() & 0xff);
    ctrlOutput.println(cmd);
    ctrlOutput.flush();
    ctrlOutput.println(ctrlcmd);
    ctrlOutput.flush();
    Socket dataSocket = serverDataSocket.accept();
    serverDataSocket.close();
    return dataSocket;
    }

    Or just use a java.net.URL("ftp://...) ..., get its input stream, and away you go ...

  • Download file from ftp server

    Can I download files from an ftp server by simply using the ip address or https:// url?    I've only gotten this to work by using the "ftp//:" address in previous projects and I'm not getting this to work in many different attempts. 
    Here is one...
     # FTP Config
    $FTPHost =
    "10.10.10.5"
    $Username =
    "admin"
    $Password =
    "12345678"
    $FTPFile =
    "test.log"
    # FTP Log File Url
    $FTPFileUrl =
    "ftp://" +
    $FTPHost +
    "/" +
    $FTPFile
    # Create FTP Connection
    $FTPRequest =
    [System.Net.FtpWebRequest]::Create("$FTPFileUrl")
    $FTPRequest.Credentials
    = New-Object System.Net.NetworkCredential($Username,
    $Password)
    $FTPRequest.Method =
    [System.Net.WebRequestMethods+Ftp]::DownloadFile
    $FTPRequest.UsePassive
    = $false
    $FTPRequest.UseBinary
    = $true
    $FTPRequest.KeepAlive
    = $false
    # Get FTP File
    $FTPResponse =
    $FTPRequest.GetResponse()
    $ResponseStream =
    $FTPResponse.GetResponseStream()
    $FTPReader =
    New-Object System.IO.Streamreader
    -ArgumentList $ResponseStream
    do
    Write-Host
    $FTPReader.ReadLine()
    while ($FTPReader.ReadLine()
    -ne $null)
    $FTPReader.Close()
    # Create FTP Connection
    $FTPRequest =
    [System.Net.FtpWebRequest]::Create("$FTPFileUrl")
    $FTPRequest.Credentials
    = New-Object System.Net.NetworkCredential($Username,
    $Password)
    $FTPRequest.Method =
    [System.Net.WebRequestMethods+Ftp]::DownloadFile
    $FTPRequest.UsePassive
    = $false
    $FTPRequest.UseBinary
    = $true
    $FTPRequest.KeepAlive
    = $false
    # Get FTP File
    $FTPResponse =
    $FTPRequest.GetResponse()
    $ResponseStream =
    $FTPResponse.GetResponseStream()
    $FTPReader =
    New-Object System.IO.Streamreader
    -ArgumentList $ResponseStream
    do
    Write-Host
    $FTPReader.ReadLine()
    while ($FTPReader.ReadLine()
    -ne $null)
    $FTPReader.Close()

    Hi!
    You don't need to specifically use an IP address. E.g can use
    $FTPHost = "myrandomserver.mycompany.com"
    $Username = "admin"
    $Password = "12345678"
    $FTPFile = "test.log"
    # FTP Log File Url
    $FTPFileUrl = "ftp://" + $FTPHost + "/" + $FTPFile

  • How to download files from Application Server of Unix o.s to local director

    Hi All,
    I am trying to download files from Apllication server of Unix operating Systems to local file in excel sheet format using a z-program.but whenever I am trying to use OPEN dataset ........
    it is showing sy-subrc = 8.
    Can I have any clew please.
    Thanks in advance,
    Regards,
    AMEER.

    Hi Sreekanth,
    Thanks a lot for quick reply.I have to download that files from z-program only. I am giving you my code below.
    *& Report  ZTRAK_DOWNLOAD                                         *
    REPORT  ZTRAK_DOWNLOAD  MESSAGE-ID ZCT                   .
    SELECTION-SCREEN BEGIN OF BLOCK DOWNLOAD WITH FRAME TITLE TEXT1.
      PARAMETERS :
           SERDIR LIKE RLGRAP-FILENAME DEFAULT '/usr/trak',
           LOCDIR LIKE RLGRAP-FILENAME DEFAULT 'C:\Trak'.
    SELECTION-SCREEN END OF BLOCK DOWNLOAD .
    SELECTION-SCREEN BEGIN OF BLOCK INFO2 WITH FRAME.
           SELECTION-SCREEN COMMENT 1(79) TEXT2.
           SELECTION-SCREEN SKIP.
           SELECTION-SCREEN COMMENT 1(79) TEXT3.
    SELECTION-SCREEN END OF BLOCK INFO2 .
    SELECTION-SCREEN BEGIN OF BLOCK INFO3 WITH FRAME.
           SELECTION-SCREEN COMMENT 1(79) TEXT4.
           SELECTION-SCREEN SKIP.
           SELECTION-SCREEN COMMENT 1(79) TEXT5.
            SELECTION-SCREEN SKIP.
           SELECTION-SCREEN COMMENT 1(79) TEXT6.
           SELECTION-SCREEN SKIP 1.
           SELECTION-SCREEN COMMENT 1(79) TEXT7.
           SELECTION-SCREEN SKIP 2.
           SELECTION-SCREEN COMMENT 1(79) TEXT8.
    SELECTION-SCREEN SKIP 1.
           SELECTION-SCREEN COMMENT 1(79) TEXT9.
    SELECTION-SCREEN END OF BLOCK INFO3.
    *- Internal Table to output data in Excel
    DATA: BEGIN OF tab_excel OCCURS 0,
            col1(50),
            col2(132),
            col3(255),
            col4(100),
            col5(100),
            col6(50),
            COL7(60),
            col8(30),
            col9(30),
            col10(30),
            col11(20),
            col12(15),
            col13(15),
          END OF tab_excel.
    DATA: FILE LIKE RLGRAP-FILENAME .
    DATA: W_DATASET(80).
    INITIALIZATION.
      TEXT1  = 'Download Reports'.
      TEXT2 = 'The Program downloads the reports generated by Trak'.
      TEXT3 = 'Utility from Server to Local PC.'.
      TEXT4 = 'Check the following before executing the Program.'.
      TEXT5 = '     1. A valid Server path is provided.'.
      TEXT6 = '     2. A valid Local PC path is provided.'.
      TEXT7 = '     3. Local PC has 10 MB free space.'.
      TEXT8 = 'The report can be executed in the forground.'.
    TEXT9 =
    'The report should be executed after execution of Transaction TRAK'.
    AT SELECTION-SCREEN.
    IF SERDIR EQ ''.
    MESSAGE E001(ZCT).
    ENDIF.
    IF LOCDIR EQ ''.
    MESSAGE E002(ZCT).
    ENDIF.
    START-OF-SELECTION.
    Download ABAP Development Summary Report
    FILE =  '\ABAP_Report_Developments.XLS'.
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/ABAP_Report_Developments.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    Download BDC Development Report
    FILE =  '\BDC_Developments_Report.XLS'.
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/BDC_Developments_Report.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    Download Development Summary Report
    FILE = '\Developments_Summary_Report.XLS' .
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/Developments_Summary_Report.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    Download Enhancement Development Report
    FILE =  '\Enhancement_Developments_Report.XLS'.
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/Enhancement_Developments_Report.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    Download field exit Development Report
    FILE =  '\Field_Exit_Developments_Report.XLS'.
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/Field_Exit_Developments_Report.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    Download Frequency & Purpose Report
    FILE =  '\Frequency_And_Purpose_Report.XLS'.
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/Frequency_And_Purpose_Report.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    Download Function Group Developments Report
    FILE =  '\FunctionGroup_Developments_Report.XLS'.
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/FunctionGroup_Developments_Report.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    Download Function Module Developments Report
    FILE = '\FunctionModule_Developments_Report.XLS' .
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/FunctionModule_Developments_Report.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    Download Include Developments Report
    FILE =  '\Include_Developments_Report.XLS'.
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/Include_Developments_Report.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    Download UserGroup Developments Report
    FILE =  '\UserGroup_Developments_Report.XLS'.
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/UserGroup_Developments_Report.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    Download Modified_Standard_SAP_Objects_Report
    FILE = '\Modified_Standard_SAP_Objects_Report.XLS' .
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/Modified_Standard_SAP_Objects_Report.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    Download Include Developments Report
    *FILE =  '\Include_Developments_Report.XLS'.
    *CONCATENATE LOCDIR FILE INTO FILE.
    *W_DATASET = '/Include_Developments_Report.dat'.
    *CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    *PERFORM INIT.
    Download SAP Script Developments Report
    FILE =  '\SAP_Scipt_Developments_Report.XLS'.
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/SAP_Scipt_Developments_Report.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    Download Transaction Developments Report
    FILE =  '\Transaction_Developments_Report.XLS'.
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/Transaction_Developments_Report.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    Download User Exits Developments Report
    FILE =  '\UserExits_Reports.XLS'.
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/UserExits_Reports.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    Download ABAP Query Developments Report
    FILE =  '\ABAPQuery_Developments_Reports.XLS'.
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/ABAPQuery_Developments_Reports.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    Download Functional Area Developments Report
    FILE =  '\FunctionalArea_Developments_Report.XLS'.
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/FunctionalArea_Developments_Report.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    MESSAGE S003(ZCT) WITH LOCDIR.
    END-OF-SELECTION.
    This routine checks whether file exists if yes downloads it to
    the Local PC
    FORM INIT.
    OPEN DATASET W_DATASET FOR INPUT IN TEXT MODE ENCODING DEFAULT.
    DO.
       IF SY-SUBRC <> 0.
          EXIT.
       ENDIF.
       READ DATASET W_DATASET INTO  tab_excel.
       APPEND tab_excel.
       CLEAR tab_excel.
    ENDDO.
         PERFORM DOWNLOAD_FILE.
    ENDFORM.
    This routine downloads the data in an XL format on local PC
    FORM Download_File .
      CALL FUNCTION 'WS_DOWNLOAD'
                EXPORTING
                     FILENAME                = FILE
                     FILETYPE                = 'DAT'
                TABLES
                     DATA_TAB                = tab_excel
                EXCEPTIONS
                     FILE_OPEN_ERROR         = 1
                     FILE_WRITE_ERROR        = 2
                     INVALID_FILESIZE        = 3
                     INVALID_TYPE            = 4
                     NO_BATCH                = 5
                     UNKNOWN_ERROR           = 6
                     INVALID_TABLE_WIDTH     = 7
                     GUI_REFUSE_FILETRANSFER = 8
                     CUSTOMER_ERROR          = 9
                     OTHERS                  = 10.
        IF sy-subrc <> 0.
         message ''.       " Error in file transfer
        ELSE.
          CLEAR TAB_EXCEL.
          REFRESH TAB_EXCEL.
          FILE = ''.
          W_DATASET = ''.
        ENDIF.
    ENDFORM.
    I have created those files in Application Server running in another z-program in background mode.Then I am trying to download those files using above the program.I am creating those trak/Trak files manually and I can able to see those files in A.S level.But when downloading the same files I am facing the problem.
    regards,
    Ameer

Maybe you are looking for

  • Structural profile for HR conflicts with MRS

    Hi, We have ECC 6.0 and implemented mini-HR for mainly CATS use and to create the organisation for MRS (multi-resource scheduling). Now we are facing problems with managers who need to have a structural profiles to limit their access to HR informatio

  • Error in attaching to container node - The code returned was 404

    I have a customer who has messed with their NTCWS and I'm trying to resurect it. I've been able to setup the correct Remote Server, Crawler Web Service (.NET CWS etc), Data Source - Remote (.NET CWS Data Source), Crawler and Job etc., but the job alw

  • Ipod touch doesnt get recognized by windows or itunes?

    okay so just recently i would plug in my ipod touch and the little noise windows makes to say that something has been plugged in rings except itunes wont recognize it or windows will make it seem like its not even there like its plugged in but a ghos

  • Sond problems on new Mac Pros (2010)??? Buying new tower advice.

    Hi all!!! Has any one here have sound problems with the new Mac Pros (2010)??? I hear they still have sound "pops" or something like that as with the 2009 MP. I'm looking to buy a new MP since my G5 tower just died today (RIP) so need a new tower but

  • DW CS3 and Flash Player 8

    Myself and colleagues, using the various CS3 tools, have recently come across a worrying problem in Dreamweaver CS3. We create Flash movies and save them out in Flash 8 format, so that they can be played on machines with Flash Player v8 without the u