You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
1.6 KiB
Java
67 lines
1.6 KiB
Java
FTPLogin
|
|
|
|
import java.io.BufferedReader;
|
|
import java.io.PrintWriter;
|
|
import java.io.InputStreamReader;
|
|
import java.net.Socket;
|
|
|
|
public class FTPLogin
|
|
{
|
|
public static void main (String args[])
|
|
{
|
|
Socket socket = null;
|
|
BufferedReader in = null;
|
|
PrintWriter out = null;
|
|
String line = null;
|
|
|
|
if (args.length != 3)
|
|
{
|
|
System.out.println ("USAGE: IP USER PASS");
|
|
}
|
|
|
|
else
|
|
{
|
|
try
|
|
{
|
|
socket = new Socket (args[0], 21);
|
|
in = new BufferedReader (new InputStreamReader(socket.getInputStream()));
|
|
out = new PrintWriter (socket.getOutputStream());
|
|
|
|
out.print("user "+ args[1] + "
|
|
");
|
|
out.print("pass "+ args[2] + "
|
|
");
|
|
out.print ("pwd
|
|
");
|
|
out.print ("quit
|
|
");
|
|
out.flush();
|
|
|
|
while ( (line = in.readLine()) != null)
|
|
{
|
|
System.out.println(line);
|
|
}
|
|
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
System.out.println(e.getMessage());
|
|
}
|
|
finally
|
|
{
|
|
try
|
|
{
|
|
out.close();
|
|
in.close();
|
|
socket.close();
|
|
}
|
|
catch (Exception fe)
|
|
{
|
|
System.out.println ("RESOURCE CLOSE EXCEPTION " +fe.getMessage());
|
|
}
|
|
}
|
|
} //end else
|
|
} //end main
|
|
} //end class
|