0

I want to connect through FTP to a Mainframe server. I can't do a direct FTP using prebuilt java libraries. I can open a command prompt and then do the actions though. I tried to automate this and get a java function do this for me. So I created a cmd window in java and connected to the FTP. I am not sure how we can pass the username and password to it.

This is my code for now :

public class CMDWindow {
    public static void main(String[] args) throws IOException {
        Runtime rt = Runtime.getRuntime();
        rt.exec("cmd.exe /c start ftp *ip*");
    }    
}

And below is what my cmd displays:

Connected to *ip*.
Username:

How can I pass the username and password to it using java?

Hello Man
  • 693
  • 2
  • 12
  • 29
  • *I can't do a direct FTP using prebuilt java libraries*: Why? – Martin Prikryl May 27 '16 at 07:03
  • I am trying to connect to a Mainframe and that doesn't respect the standard java ftp open connection commands that the program sends it but respects the ftp open connection command send using cmd window – Hello Man May 27 '16 at 07:08
  • What open connection commands? Should should rather ask how to make the native Java libraries working that to hack it by running command-line `ftp`. – Martin Prikryl May 27 '16 at 07:10

0 Answers0