public Object execute(ShellSession session, String[] args) { System.out.println(session.getEnv().get("$CWD")); return null; }
public Object execute(ShellSession session, String[] args) { System.out.println(session.getEnv().get("$CWD")); return null; }
public Object execute(ShellSession session, String[] args) { System.out.println(session.getEnv().get("$CWD")); return null; }
public Object execute(ShellSession session, String[] args) { File current = new File(session.getEnv().get("$CWD")); if (!current.isDirectory()) throw new CommandException("cannot list directory : " + session.getEnv().get("$CWD") + " is not a directory"); File[] files = current.listFiles(); if (files.length == 0) return null; else { System.out.append("Total ").append(String.valueOf(files.length)).append("\n"); } for (File file : current.listFiles()) { if (file.isDirectory()) { System.out.append(file.getName()).append("/"); } else { System.out.append(file.getName()); } System.out.append("\n"); } System.out.flush(); return null; }
public Object execute(ShellSession session, String[] args) { File current = new File(session.getEnv().get("$CWD")); if (!current.isDirectory()) throw new CommandException("cannot list directory : " + session.getEnv().get("$CWD") + " is not a directory"); File[] files = current.listFiles(); if (files.length == 0) return null; else { System.out.append("Total ").append(String.valueOf(files.length)).append("\n"); } for (File file : current.listFiles()) { if (file.isDirectory()) { System.out.append(file.getName()).append("/"); } else { System.out.append(file.getName()); } System.out.append("\n"); } System.out.flush(); return null; }
public Object execute(ShellSession session, String[] args) { File current = new File(session.getEnv().get("$CWD")); if (!current.isDirectory()) throw new CommandException("cannot list directory : " + session.getEnv().get("$CWD") + " is not a directory"); File[] files = current.listFiles(); if (files.length == 0) return null; else { System.out.append("Total ").append(String.valueOf(files.length)).append("\n"); } for (File file : current.listFiles()) { if (file.isDirectory()) { System.out.append(file.getName()).append("/"); } else { System.out.append(file.getName()); } System.out.append("\n"); } System.out.flush(); return null; }
public Object execute(ShellSession session, String[] args) { File cwd = new File(session.getEnv().get("$CWD")); if (args.length == 0 || ".".equals(args[0])) return null; else if ("..".equals(args[0])) { if (cwd.getParentFile() != null) { cwd = cwd.getParentFile(); } else { throw new CommandException("already at top-level directory"); } } else if (args[0].charAt(0) == '/') { cwd = new File(args[0]); if (!cwd.exists()) { throw new CommandException("no such directory: " + args[0]); } } else { cwd = new File(cwd.getAbsolutePath() + "/" + args[0]); if (!cwd.exists()) { throw new CommandException("no such directory: " + args[0]); } } session.getEnv().put("$CWD", cwd.getAbsolutePath()); return null; }
public Object execute(ShellSession session, String[] args) { File cwd = new File(session.getEnv().get("$CWD")); if (args.length == 0 || ".".equals(args[0])) return null; else if ("..".equals(args[0])) { if (cwd.getParentFile() != null) { cwd = cwd.getParentFile(); } else { throw new CommandException("already at top-level directory"); } } else if (args[0].charAt(0) == '/') { cwd = new File(args[0]); if (!cwd.exists()) { throw new CommandException("no such directory: " + args[0]); } } else { cwd = new File(cwd.getAbsolutePath() + "/" + args[0]); if (!cwd.exists()) { throw new CommandException("no such directory: " + args[0]); } } session.getEnv().put("$CWD", cwd.getAbsolutePath()); return null; }
public Object execute(ShellSession session, String[] args) { File cwd = new File(session.getEnv().get("$CWD")); if (args.length == 0 || ".".equals(args[0])) return null; else if ("..".equals(args[0])) { if (cwd.getParentFile() != null) { cwd = cwd.getParentFile(); } else { throw new CommandException("already at top-level directory"); } } else if (args[0].charAt(0) == '/') { cwd = new File(args[0]); if (!cwd.exists()) { throw new CommandException("no such directory: " + args[0]); } } else { cwd = new File(cwd.getAbsolutePath() + "/" + args[0]); if (!cwd.exists()) { throw new CommandException("no such directory: " + args[0]); } } session.getEnv().put("$CWD", cwd.getAbsolutePath()); return null; }
public Object execute(ShellSession session, String[] args) { Map<String, String> env = session.getEnv(); if (args.length == 0) { for (String var : env.keySet()) { System.out.println(var + " = " + env.get(var)); } } else if (args.length == 1) { throw new CommandException("incorrect number of parameters"); } else { StringAppender sbuf = new StringAppender(); for (int i = 1; i < args.length; i++) { sbuf.append(args[i]); if (i < args.length) sbuf.append(" "); } env.put(args[0], sbuf.toString().trim()); } return null; }
public Object execute(ShellSession session, String[] args) { Map<String, String> env = session.getEnv(); if (args.length == 0) { for (String var : env.keySet()) { System.out.println(var + " = " + env.get(var)); } } else if (args.length == 1) { throw new CommandException("incorrect number of parameters"); } else { StringAppender sbuf = new StringAppender(); for (int i = 1; i < args.length; i++) { sbuf.append(args[i]); if (i < args.length) sbuf.append(" "); } env.put(args[0], sbuf.toString().trim()); } return null; }
public Object execute(ShellSession session, String[] args) { Map<String, String> env = session.getEnv(); if (args.length == 0) { for (String var : env.keySet()) { System.out.println(var + " = " + env.get(var)); } } else if (args.length == 1) { throw new CommandException("incorrect number of parameters"); } else { StringAppender sbuf = new StringAppender(); for (int i = 1; i < args.length; i++) { sbuf.append(args[i]); if (i < args.length) sbuf.append(" "); } env.put(args[0], sbuf.toString().trim()); } return null; }