-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCSftp.java
More file actions
executable file
·58 lines (46 loc) · 1.48 KB
/
CSftp.java
File metadata and controls
executable file
·58 lines (46 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
* Created by linda on 2/2/2017.
*/
public class CSftp {
public static void main(String [] args){
String hostname = null;
int port;
/*
default port is 21 if not specified
*/
try{
hostname = args[0];
port = Integer.parseInt(args[1]);
}catch(ArrayIndexOutOfBoundsException e){
port = 21;
}
// connect to command socket
theSocket kkSocket = new theSocket(hostname, port);
Utils.setIPandPort(hostname, port);
kkSocket.createSocket("command");
Command command = new Command();
fromServer server = new fromServer(kkSocket, command);
BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in)); // accept user input
server.printResponse();
String fromUser = "";
while(true){
System.out.print("csftp> ");
try{
fromUser = stdIn.readLine();
}catch(IOException e){
Utils.errorMessage("FFFE");
}
if( !command.commandExist(fromUser) )
Utils.errorMessage("001");
else if( !Utils.argumentChecker(fromUser) )
Utils.errorMessage("002");
else if(fromUser.equals("quit")){
break;
}
else server.takeInput(fromUser);
}
}
}