0

I am writing a small FTPS client that will download Enscribe files from NonStop/Tandem and will be processes in Windows. I am using the Apache Commons Net API to achieve this.

I am able to download and upload files from and to NonStop/Tandem. But I am not able to list the files and the directories using the listFiles() and/or mlistDir() methods present under org.apache.commons.net.ftp.FTPClient class.

Below is my code to list the files present in the current working directory.

FTPSClient client = new FTPSClient(false);
try {
    client.connect(serverAddress, serverPort);
    if (FTPReply.isPositiveCompletion(client.getReplyCode())) {
        if (client.login(userName, passwd)) {
            System.out.println(client.getReplyString());

            // Set protection buffer size
            client.execPBSZ(0);

            // Set data channel protection to private
            client.execPROT("P");

            // Enter local passive mode
            client.enterLocalPassiveMode();

            // Get Current Working Directory
            client.printWorkingDirectory();
            System.out.println(client.getReplyString());

            FTPFile[] files = client.listFiles();

            // Logout
            client.logout();
            System.out.println(client.getReplyString());

        } else {
            System.out.println("Login failed...");
    }

    // Disconnect from Server
    client.disconnect();
    System.out.println("Disconnected from Host...");
    } else {
        System.out.println("Connection to Host failed...");
        System.out.println("Error Code - " + reply);
    }

    } catch (Exception e) {
        e.printStackTrace();
    }

I get the following error while executing the code:

org.apache.commons.net.ftp.parser.ParserInitializationException: Unknown parser type: Nonstop J-series Server : J06.19.
    at org.apache.commons.net.ftp.parser.DefaultFTPFileEntryParserFactory.createFileEntryParser(DefaultFTPFileEntryParserFactory.java:169)
    at org.apache.commons.net.ftp.parser.DefaultFTPFileEntryParserFactory.createFileEntryParser(DefaultFTPFileEntryParserFactory.java:94)
    at org.apache.commons.net.ftp.FTPClient.__createParser(FTPClient.java:3377)
    at org.apache.commons.net.ftp.FTPClient.initiateListParsing(FTPClient.java:3334)
    at org.apache.commons.net.ftp.FTPClient.listFiles(FTPClient.java:3012)
    at org.apache.commons.net.ftp.FTPClient.listFiles(FTPClient.java:3065)
    at com.connect.ssl.FTPSTest.main(FTPSTest.java:57)

I even tried to set the FTPClient configuration as UNIX as below, but it didn't helped.

client.configure(new FTPClientConfig(FTPClientConfig.SYST_UNIX));

Can anyone help me with this.

Ajitav Dutta
  • 99
  • 1
  • 11
  • The error messages says that the parser type is unknown. That should be a good starting point. – Lajos Arpad Oct 07 '16 at 17:52
  • The NonStop isn't listed in the set of system types [here](https://commons.apache.org/proper/commons-net/apidocs/constant-values.html#org.apache.commons.net.ftp.FTPClient.FTP_SYSTEM_TYPE). Your best bet may be to treat it as a UNIX type machine. In that case you have to force the OSS personality, either by issuing a quote("oss") command if quote is supported in that class or by configuring the underlying Safeguard user to have an initial OSS directory. That will make the file-system appear to be UNIX like rather than Guardian style. – Andy Simpson Oct 09 '16 at 06:39
  • @AndySimpson Thanks, I am able to get the list of all the files present in the directory. But I am not able to go back to Guardian/TACL for downloading and uploading the files. – Ajitav Dutta Oct 10 '16 at 04:39
  • If the files are not on a virtual disk then you should be able to access them via ftp - the Guardian files have an OSS path like /G/system/system/cextdecs for $system.system.cextdecs. I would think that is transparent to the Java stuff. If your files are on a virtual disk then you have problems as OSS and virtual disks don't play well together. Can you do everything that you want to do from an ftp command prompt (say in Windows) ? – Andy Simpson Oct 11 '16 at 23:23
  • @AndySimpson Unfortunately the files are in virtual disks. For now I am disconnecting the connection once I list the files under a sub-volume and then if the users wants to upload/download the file then I am re-initiating the connection as Guardian to do download/upload. – Ajitav Dutta Oct 12 '16 at 14:36

0 Answers0