1 //////////////////////////////////////////////////////////////////////////
2 // Copyright (C) Kong Jian-jun, Apr. 2007.
3 // Implemented XylFTPCLI.ShowHelp(), XylFTPCLI.ProcessEcho(), etc.
4 // Copyright (C) Wang Cong, Apr. 2007.
5 // Implemented XylFTPCLI.ParseInput().
6 // Hacked by Zhou Xiao-wei, May. 2007.
7 // See AUTHORS and CREDITS to learn more.
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License version 2 as
10 // published by the Free Software Foundation.
11 // See COPYING to learn more.
12 //////////////////////////////////////////////////////////////////////////
18 *This is class Command-line interface.
19 *Extends XylFTPConnection.
20 *Implements XylFTPInterface.
21 *@see XylFTPConnection
23 *@author WANG Cong, KONG Jian-Jun
26 public class XylFTPCLI
extends XylFTPConnection
implements XylFTPInterface
{
30 private String UserName
;
35 private String PassWord
;
38 *Presents the input of user.
40 private String UserInput
;
43 *The current working directory on local host.
45 private File CurrentDir
;
48 *Sets the default password.
50 private final String DefaultPass
= "xylftpuser@xylftp";
55 private String
[] commands
= {"help", "?", "ls", "lls",
56 "dir", "get", "put", "cwd", "cd", "lcwd", "lcd", "pwd",
57 "lpwd", "passive", "cdup", "lcdup", "quit", "bye",
58 "open", "close", "user", "!!", "delete", "rmdir",
59 "mkdir", "chmod", "size", "rename", "type", "status",
60 "quote", "verbose", "debug"};
63 *Initializes some values.
67 UserName
= "anonymous";
68 PassWord
= DefaultPass
;
69 File f
= new File(".");
71 CurrentDir
= new File(f
.getCanonicalPath());
72 } catch (Exception e
) {
73 System
.out
.println("Fatal: Can't get current directory!");
80 *@param NewName the new user name.
82 public void SetUserName(String NewName
){
87 *Returns the username.
90 public String
GetUserName(){
96 *@param NewPass the new password.
98 public void SetPassWord(String NewPass
){
106 public String
GetPassWord(){
111 *Splits the command string into commands list.
113 *@return the string of command
115 public String
[] MakeCommands(String Command
){
119 nstr
= Command
.split("\r\n");
124 *Counts the number of arguments.
125 *@param Str the input
126 *@return the number of arguments in Str
128 private int CountArgs(String Str
){
130 nstr
= Str
.split("[\t ]+");
135 *Look up the commands list, recognize which command matches.
136 *@return the index of the command, -1 on failure.
138 private int LookupCommands(String input
) throws Exception
{
140 for (; i
< commands
.length
; i
++) {
141 if (StartsOnlyWith(input
, commands
[i
]))
144 //If not found, try again for incomplete input.
145 boolean found_one
= false;
147 for (i
= 0; i
< commands
.length
; i
++) {
148 if (commands
[i
].startsWith(input
.toLowerCase())) {
164 *@param CmdString the command of the user input
165 *@param Cmd the handled command
166 *@throws XylFTPException on dealing with command error
167 *@return true while right,false while wrong
169 private boolean StartsOnlyWith(String CmdString
, String Cmd
) throws Exception
{
170 switch(CountArgs(CmdString
)){
172 if (CmdString
.equalsIgnoreCase(Cmd
))
177 String
[]cmds
= CmdString
.split("[\t ]+");
178 if(cmds
[0].equalsIgnoreCase(Cmd
))
186 *Translates the command for FTP protocol.
187 *@param Input the input of the user
188 *@return ehco for input
190 *@see XylFTPException
191 *@throws XylFTPException on parsing input error
193 private String
ParseInput(String Input
) throws Exception
{
194 String tmp
= Input
.trim();
197 switch (LookupCommands(tmp
)) {
201 switch (CountArgs(tmp
)){
206 String
[]cmds
= tmp
.split("[\t ]+");
210 throw new XylFTPException("help", "Too many arguments.");
217 throw new XylFTPException("ls", "Can't execute it now. Try again later.");
218 switch (CountArgs(tmp
)){
222 return "PASV\r\nLIST\r\n";
224 return "PORT "+GetSelfIP()+GetSelfPort()+"\r\nLIST\r\n";
226 String
[]cmds
= tmp
.split("[\t ]+");
228 for(int i
=1; i
< cmds
.length
; i
++)
229 substr
= substr
+ cmds
[i
] + " ";
231 substr
= substr
.trim();
233 return "PASV\r\nLIST "+substr
+"\r\n";
235 return "PORT "+GetSelfIP()+GetSelfPort()+"\r\nLIST "+substr
+"\r\n";
240 switch (CountArgs(tmp
)){
242 String
[] list
= CurrentDir
.list();
243 for (int i
=0; i
< list
.length
; i
++) {
244 System
.out
.println(list
[i
]);
248 String
[]cmds
= tmp
.split("[\t ]+");
250 for (int i
=1; i
< cmds
.length
; i
++) {
251 f2
= new File(CurrentDir
.getCanonicalPath()+File
.separator
+cmds
[i
]);
253 System
.out
.println(cmds
[i
]+" doesn't exist.");
257 System
.out
.println(cmds
[i
]);
258 if (f2
.isDirectory()){
259 System
.out
.println(cmds
[i
]+":");
260 String
[] lst
= f2
.list();
261 for(int j
=0; j
< lst
.length
; j
++)
262 System
.out
.println("\t"+lst
[j
]);
272 throw new XylFTPException("dir", "Can't execute it now. Try again later.");
273 switch (CountArgs(tmp
)){
277 return "PASV\r\nNLST\r\n";
279 return "PORT "+GetSelfIP()+GetSelfPort()+"\r\nNLST\r\n";
281 String
[]cmds
= tmp
.split("[\t ]+");
283 for(int i
=1; i
< cmds
.length
; i
++)
284 substr
= substr
+ cmds
[i
] + " ";
286 substr
= substr
.trim();
288 return "PASV\r\nNLST "+substr
+"\r\n";
290 return "PORT "+GetSelfIP()+GetSelfPort()+"\r\nNLST "+substr
+"\r\n";
296 throw new XylFTPException("get", "You can't excute it now. Try again later.");
297 switch (CountArgs(tmp
)){
299 throw new XylFTPException("get", "Missed arguments.");
301 String
[]cmds
= tmp
.split("[\t ]+");
302 String tmp3
= cmds
[1];
303 if (cmds
[1].charAt(0)!='/')
304 tmp3
= CurrentDir
.getCanonicalPath()+File
.separator
+cmds
[1];
305 int p
= tmp3
.lastIndexOf("/");
307 File d
= new File(tmp3
.substring(0, p
));
309 throw new XylFTPException("get", "Directory doesn't exist.");
312 File f
= new File(tmp3
);
314 throw new XylFTPException("get", "can't gets to a directory.");
316 return "PASV\r\nRETR "+cmds
[1]+"\r\n";
318 return "PORT "+GetSelfIP()+GetSelfPort()+"\r\nRETR "+cmds
[1]+"\r\n";
320 String
[]cmds2
= tmp
.split("[\t ]+");
321 String tmp4
= cmds2
[2];
322 if (cmds2
[2].charAt(0)!='/')
323 tmp4
= CurrentDir
.getCanonicalPath()+File
.separator
+cmds2
[2];
324 int q
= tmp4
.lastIndexOf("/");
326 File d2
= new File(tmp4
.substring(0, q
));
328 throw new XylFTPException("get", "Directory doesn't exist.");
331 File f2
= new File(tmp4
);
332 if (f2
.isDirectory())
333 throw new XylFTPException("get", "can't gets to a directory.");
335 return "PASV\r\nRETR "+cmds2
[1]+"\r\n";
337 return "PORT "+GetSelfIP()+GetSelfPort()+"\r\nRETR "+cmds2
[1]+"\r\n";
339 throw new XylFTPException("get", "Too many arguments.");
345 throw new XylFTPException("put", "You can't excute it now. Try again later.");
346 switch (CountArgs(tmp
)){
348 throw new XylFTPException("put", "Missed arguments.");
350 String
[]cmds
= tmp
.split("[\t ]+");
351 String tmp1
= cmds
[1];
352 if (cmds
[1].charAt(0)!='/')
353 tmp1
= CurrentDir
.getCanonicalPath()+File
.separator
+cmds
[1];
355 File f
= new File(tmp1
);
357 throw new XylFTPException("put", "file doesn't exist.");
359 throw new XylFTPException("put", "can't puts from a directory.");
361 return "PASV\r\nSTOR "+cmds
[1]+"\r\n";
363 return "PORT "+GetSelfIP()+GetSelfPort()+"\r\nSTOR "+cmds
[1]+"\r\n";
365 String
[]cmds2
= tmp
.split("[\t ]+");
366 String tmp2
= cmds2
[1];
367 if (cmds2
[1].charAt(0)!='/')
368 tmp2
= CurrentDir
.getCanonicalPath()+File
.separator
+cmds2
[1];
370 File f2
= new File(tmp2
);
372 throw new XylFTPException("put", "file doesn't exist.");
373 if (f2
.isDirectory())
374 throw new XylFTPException("put", "can't puts from a directory.");
376 return "PASV\r\nSTOR "+cmds2
[2]+"\r\n";
378 return "PORT "+GetSelfIP()+GetSelfPort()+"\r\nSTOR "+cmds2
[2]+"\r\n";
380 throw new XylFTPException("put", "Too many arguments.");
387 throw new XylFTPException("cd", "You can't execute it now. Try again later.");
388 switch (CountArgs(tmp
)){
392 String
[]cmds
= tmp
.split("[\t ]+");
393 return "CWD "+cmds
[1]+"\r\n";
395 throw new XylFTPException("cd", "Too many arguments.");
401 switch (CountArgs(tmp
)){
405 String
[]cmds
= tmp
.split("[\t ]+");
406 if (cmds
[1].equals("."))
408 else if (cmds
[1].equals("..")) {
409 String parent
= CurrentDir
.getAbsoluteFile().getParent();
413 System
.out
.println("cd into: "+parent
);
414 CurrentDir
= new File(parent
);
416 } else if (cmds
[1].charAt(0)=='/') {
417 File ff
= new File(cmds
[1]);
418 if(!ff
.exists() || !ff
.isDirectory())
419 System
.out
.println(cmds
[1]+": No such dir.");
422 System
.out
.println("cd into: "+CurrentDir
.getCanonicalPath());
426 File fl
= new File(CurrentDir
.getCanonicalPath()+File
.separator
+cmds
[1]);
427 if(!fl
.exists() || !fl
.isDirectory())
428 System
.out
.println(cmds
[1]+": No such dir.");
431 System
.out
.println("cd into: "+CurrentDir
.getCanonicalPath());
436 throw new XylFTPException("cd", "Too many arguments.");
443 throw new XylFTPException("pwd", "You can't execute it now. Try again later.");
444 switch (CountArgs(tmp
)){
448 throw new XylFTPException("pwd", "It doesn't accept any arguments.");
453 switch (CountArgs(tmp
)){
455 System
.out
.println(CurrentDir
.getCanonicalPath());
458 throw new XylFTPException("lpwd", "It doesn't accept any arguments.");
464 switch (CountArgs(tmp
)){
466 String
[]cmds
= tmp
.split("[\t ]+");
467 if (!cmds
[1].equals("on") && !cmds
[1].equals("off"))
468 throw new XylFTPException("passive", "Wrong arugment.");
470 if (cmds
[1].equals("on")) {
471 System
.out
.println("Passive mode on.");
474 System
.out
.println("Passive mode off.");
480 throw new XylFTPException("passive", "It must have an argument.");
482 throw new XylFTPException("passive", "Too many arguments.");
489 throw new XylFTPException("cdup",
490 "Can't execute it now. Try again later.");
491 switch (CountArgs(tmp
)){
495 throw new XylFTPException("cdup",
496 "It doesn't accept any arguments.");
501 switch (CountArgs(tmp
)){
503 String parent
= CurrentDir
.getAbsoluteFile().getParent();
507 System
.out
.println("cd into: "+parent
);
508 CurrentDir
= new File(parent
);
512 throw new XylFTPException("lcdup",
513 "It doesn't accept any arguments.");
520 if (CountArgs(tmp
) > 1) {
521 throw new XylFTPException("quit",
522 "It doesn't accept any arguments.");
524 switch (GetStatus()){
529 return "QUIT\r\nQUIT\r\n"; //Note! It is used to differ 'quit' from 'close'.
532 return "ABOR\r\nQUIT\r\nQUIT\r\n";
534 throw new XylFTPException("Unknown status!");
539 int n
= CountArgs(tmp
);
541 throw new XylFTPException("open",
542 "It must be followed by at least one argument.");
545 throw new XylFTPException("open", "Too many arguments.");
547 switch (GetStatus()){
551 String
[]cmds
= tmp
.split("[\t ]+");
556 portNum
= Integer
.parseInt(cmds
[2]);
557 } catch (NumberFormatException e
) {
565 String s
= GetEcho();
567 throw new XylFTPException("xylftp", 0,
568 "Cann't get an echo.");
570 System
.out
.println(s
);
571 while (s
.charAt(3) == '-'){
574 throw new XylFTPException("xylftp", 0,
575 "Can't get an echo.");
576 if (XylFTPMain
.GetEnableDebug())
577 System
.out
.println("<---"+s
);
578 System
.out
.println(s
);
581 return "USER "+UserName
+"\r\n"+"PASS "+PassWord
+"\r\n";
585 throw new XylFTPException("Connection already existed.");
587 throw new XylFTPException("panic", "Unknown status!");
592 if (CountArgs(tmp
) > 1){
593 throw new XylFTPException("close", "Too many arguments.");
595 switch (GetStatus()){
597 throw new XylFTPException("Not connected yet.");
603 return "ABOR\r\nQUIT\r\n";
605 throw new XylFTPException("Unknown status!");
610 switch (GetStatus()){
612 String
[] cmds
= tmp
.split("[\t ]+");
613 if (cmds
.length
== 2) {
616 else if (cmds
.length
== 3) {
620 else if (cmds
.length
== 1) {
621 throw new XylFTPException("user",
622 "It must be followed by at least one argument.");
625 throw new XylFTPException("user", "Too many arguments.");
627 SetUserName(UserName
);
628 SetPassWord(PassWord
);
632 String
[] cmds2
= tmp
.split("[\t ]+");
633 if (cmds2
.length
== 2) {
636 else if (cmds2
.length
== 3) {
640 else if (cmds2
.length
== 1) {
641 throw new XylFTPException("user",
642 "It must be followed by at least one argument.");
645 throw new XylFTPException("user", "Too many arguments.");
647 return "USER "+UserName
+"\r\n"+"PASS "+PassWord
+"\r\n";
650 throw new XylFTPException("user",
651 "Can't execute it now. Try again later.");
653 throw new XylFTPException("panic", "Unknown status!");
658 if (CountArgs(tmp
) > 1) {
659 throw new XylFTPException("!!", "It doesn't accept any arguments.");
661 System
.out
.println("=====Enter shell mode=====");
662 String cmd
= GetInput();
663 System
.out
.println("cmd :"+cmd
);
664 while(!cmd
.equals("exit")){
665 Runtime run
= Runtime
.getRuntime();
666 Process pp
=run
.exec(cmd
);
668 BufferedReader in
= new BufferedReader(new InputStreamReader(pp
.getInputStream()));
670 while ((line
= in
.readLine()) != null) {
671 System
.out
.println(line
);
675 System
.out
.println("=====Exit shell mode=====");
682 throw new XylFTPException("delete",
683 "Can't execute it now. Try again later.");
684 switch (CountArgs(tmp
)){
686 throw new XylFTPException("delete", "Missed arguments.");
688 String
[]cmds
= tmp
.split("[\t ]+");
689 return "DELE "+cmds
[1]+"\r\n";
691 throw new XylFTPException("delete", "Too many arguments.");
697 throw new XylFTPException("rmdir",
698 "Can't execute it now. Try again later.");
699 switch (CountArgs(tmp
)){
701 throw new XylFTPException("rmdir", "Missed arguments.");
703 String
[]cmds
= tmp
.split("[\t ]+");
704 return "RMD "+cmds
[1]+"\r\n";
706 throw new XylFTPException("rmdir", "Too many arguments.");
712 throw new XylFTPException("mkdir",
713 "Can't execute it now. Try again later.");
714 switch (CountArgs(tmp
)){
716 throw new XylFTPException("mkdir", "Missed arguments.");
718 String
[]cmds
= tmp
.split("[\t ]+");
719 return "MKD "+cmds
[1]+"\r\n";
721 throw new XylFTPException("mkdir", "Too many arguments.");
727 throw new XylFTPException("chmod",
728 "Can't execute it now. Try again later.");
729 switch (CountArgs(tmp
)){
732 throw new XylFTPException("chmod", "Missed arguments.");
734 String
[]cmds
= tmp
.split("[\t ]+");
735 return "SITE CHMOD "+cmds
[1]+" "+cmds
[2]+"\r\n";
737 throw new XylFTPException("chmod", "Too many arguments.");
743 throw new XylFTPException("size",
744 "Can't execute it now. Try again later.");
745 switch (CountArgs(tmp
)){
747 throw new XylFTPException("size", "Missed arguments.");
749 String
[]cmds
= tmp
.split("[\t ]+");
750 return "SIZE "+cmds
[1]+"\r\n";
752 throw new XylFTPException("size", "Too many arguments.");
758 throw new XylFTPException("rename",
759 "Can't execute it now. Try again later.");
760 switch (CountArgs(tmp
)){
763 throw new XylFTPException("rename", "Missed arguments.");
765 String
[]cmds
= tmp
.split("[\t ]+");
766 return "RNFR "+cmds
[1]+"\r\nRNTO "+cmds
[2]+"\r\n";
768 throw new XylFTPException("rename", "Too many arguments.");
774 switch (CountArgs(tmp
)){
776 if(GetTransferMode()==0)
777 System
.out
.println("Using binary mode to transfer files.");
779 System
.out
.println("Using ascii mode to transfer files.");
782 String
[]cmds
= tmp
.split("[\t ]+");
783 if(cmds
[1].equalsIgnoreCase("ascii"))
785 else if(cmds
[1].equalsIgnoreCase("binary"))
788 throw new XylFTPException("type", "Wrong arguments.");
790 throw new XylFTPException("type", "Too many arguments.");
796 switch (GetStatus()){
798 System
.out
.println("Not connected.");
801 System
.out
.println("Connected to "+GetHost()+",but not login.");
804 System
.out
.println("Login ("+GetHost()+") and no data transfer.");
807 System
.out
.println("Login ("+GetHost()+") and getting data down.");
810 System
.out
.println("Login ("+GetHost()+") and putting data up.");
813 throw new XylFTPException("status", "Wrong status.");
817 System
.out
.println("Passive: on");
820 System
.out
.println("Passive: off");
822 if (GetTransferMode()==0)
823 System
.out
.println("Type: binary");
825 System
.out
.println("Type: ascii");
828 if (XylFTPMain
.GetEnableVerbose()){
829 System
.out
.println("Verbose: on");
832 System
.out
.println("Verbose: off");
834 if (XylFTPMain
.GetEnableDebug()){
835 System
.out
.println("Debug: on");
838 System
.out
.println("Debug: off");
847 throw new XylFTPException("quote", "Not connection.");
848 switch(CountArgs(tmp
)){
850 System
.out
.print("Enter the command to send:");
854 in
= tmp
.substring(5, tmp
.length()).trim();
857 if (XylFTPMain
.GetEnableDebug())
858 System
.out
.println("--->" + in
);
861 if(echo
== null || !IsValidEcho(echo
))
862 throw new XylFTPException("Can't get an echo.");
863 if (XylFTPMain
.GetEnableDebug())
864 System
.out
.println("<---" + echo
);
865 ret
= ProcessEcho(echo
);
871 switch(CountArgs(tmp
)){
873 if (XylFTPMain
.GetEnableVerbose()){
874 XylFTPMain
.SetEnableVerbose(false);
875 System
.out
.println("Verbose off.");
878 XylFTPMain
.SetEnableVerbose(true);
879 System
.out
.println("Verbose on.");
883 throw new XylFTPException("verbose", "Too many arguments.");
889 switch(CountArgs(tmp
)){
891 if (XylFTPMain
.GetEnableDebug()){
892 XylFTPMain
.SetEnableDebug(false);
893 System
.out
.println("Debugging off.");
896 XylFTPMain
.SetEnableDebug(true);
897 System
.out
.println("Debugging on.");
901 throw new XylFTPException("debug", "Too many arguments.");
906 throw new XylFTPException("xylftp", GetStatus(), "Unknown command!");
912 *@return In the readline from buffer
916 public String
GetInput() throws Exception
{
917 //Why System.in.skip(System.in.available()); cann't help us?
918 BufferedReader Buf
= new BufferedReader(new InputStreamReader(System
.in
));
919 String In
= Buf
.readLine();
924 *Shows the echo from server.
927 private void ShowEcho(String Echo
){
928 System
.out
.println(Echo
);
932 *Determines whether the echo is valid
935 public boolean IsValidEcho(String OEcho
){
936 String Echo
= OEcho
.trim();
937 if (Echo
.length() < 4)
939 if (Echo
.charAt(0)<'0' || Echo
.charAt(0)>'9')
941 if (Echo
.charAt(1)<'0' || Echo
.charAt(1)>'9')
943 if (Echo
.charAt(2)<'0' || Echo
.charAt(2)>'9')
945 if (Echo
.charAt(3)!=' ' && Echo
.charAt(3)!='-')
951 *Process the echo from the server.
952 *@param OEcho a number returns from the server
953 *@return a number that shows the echo as a logo
955 public int ProcessEcho(String OEcho
){
956 String Echo
= OEcho
.trim();
958 if (Echo
.charAt(3) == '-')
959 return 6; //This means multi-line echo.
960 if(Echo
.substring(0,1).equals("1"))
961 return 1; //We need data connection.
962 if(Echo
.substring(0,1).equals("2")){
963 if(Echo
.substring(0,3).equals("227"))
965 else if(Echo
.substring(0,3).equals("200"))
968 return 2; //Don't to be continued.
970 if(Echo
.substring(0,1).equals("3"))
971 return 3; //Continue.
972 if(Echo
.substring (0,1).equals("4")){
973 if(Echo
.substring(0,3).equals("421")){
977 if(Echo
.substring(0,3).equals("450"))
979 return 4; //Send again.
981 if(Echo
.substring(0,1).equals("5"))
982 return 5; //Stop resending.
983 if(Echo
.substring(1,2).equals("0"))
984 return 0; //Invalid format.
986 return -1; //Unknow mistake
990 *Gets the commands that user inputs.
991 *@throws XylFTPException on getting commands error
992 *@see XylFTPException
993 *@return the handled command as a string
995 public String
[] GetCommands() throws Exception
{
996 String CmdString
= ParseInput(GetInput());
998 cmds
= MakeCommands(CmdString
);
1005 public void ShowUsage(){
1006 System
.out
.println("xylftp [-h|--help][-V | -version]");
1007 System
.out
.println("xylftp [-v|--verbose][-u $USERNAME|--user=$USERNAME][-p $PASSWORD | --password=$PASSWORD][-d|--debug] [$HOST]");
1008 System
.out
.println("");
1009 System
.out
.println("-u $username | -user=$username \n\tTry $username as username to connect to the host, if this is not specified, use anonymous as default.");
1010 System
.out
.println("-h | --help \n\tShow this help screen.");
1011 System
.out
.println("-V | -version \n\tShow version information.");
1012 System
.out
.println("-v | -verbose \n\tShow verbose information.");
1013 System
.out
.println("-p $PASSWORD | --password=$PASSWORD \n\tUse $PASSWORD as your password. If this is unspecified, use empty password as default.");
1014 System
.out
.println("-d | --debug \n\tShow more information for developers and system admins.");
1018 *Show help information.
1020 public void ShowHelp(String Command
){
1021 String help
[] = new String
[31];
1024 help
[0]="?\tprint local help information";
1025 help
[1]="bye\tterminate ftp session and exit";
1026 help
[2]="cd\tchange remote working directory";
1027 help
[3]="cdup\tchange remote working directory to parent directory";
1028 help
[4]="chmod\tchange file permissions of remote file";
1029 help
[5]="close\tterminate ftp session";
1030 help
[6]="debug\toggle/set debugging mode";
1031 help
[7]="delete\tdelete remote file";
1032 help
[8]="dir\tlist contents of remote directory";
1033 help
[9]="get\tget a file";
1034 help
[10]="help\tprint local help information";
1035 help
[11]="lcd\tchange local working directory";
1036 help
[12]="lcdup\tget to local parent directory";
1037 help
[13]="lcwd\tchange local working directory";
1038 help
[14]="lls\tlist contents of local directory";
1039 help
[15]="lpwd\tprint working directory on local machine";
1040 help
[16]="ls\tlist contents of remote directory";
1041 help
[17]="mkdir\tmake directory on the remote machine";
1042 help
[18]="open\tconnect to remote ftp";
1043 help
[19]="passive\tturn passive transfer mode on/off";
1044 help
[20]="put\tsend one file";
1045 help
[21]="pwd\tprint working directory on remote machine";
1046 help
[22]="quit\tterminate ftp session and exit";
1047 help
[23]="quote\tsend arbitrary ftp command";
1048 help
[24]="rename\trename a file";
1049 help
[25]="rmdir\tremove directory on the remote machine";
1050 help
[26]="size\tshow size of remote file";
1051 help
[27]="status\tshow current status";
1052 help
[28]="type\tset file transfer type";
1053 help
[29]="user\tsend new user information";
1054 help
[30]="verbose\ttoggle verbose mode";
1056 if (Command
.equals("")){
1057 System
.out
.println("Help of xylftp commands:\n");
1058 while(i
< help
.length
){
1059 System
.out
.println(help
[i
]);
1063 while(i
< help
.length
){
1064 if(help
[i
].startsWith(Command
+"\t")){
1065 System
.out
.println(help
[i
]);
1070 System
.out
.println("There is no information about "+Command
);
1077 public void ShowVersion(){
1078 System
.out
.println("xylftp: version 1.1.");