@Test public void testWhoAmI() throws Exception { String username = System.getProperty("user.name"); assertEquals(username, FileTools.whoAmI()); }
public static String whoAmI() { ArrayList<String> theCommand = new ArrayList<>(); theCommand.add("bash"); theCommand.add("-lc"); theCommand.add("whoami"); ReturnValue ret = RunTools.runCommand(theCommand.toArray(new String[theCommand.size()])); if (ret.getExitStatus() == ReturnValue.SUCCESS) { String stdout = ret.getStdout(); stdout = stdout.trim(); return (stdout); } else { Log.error("Can't figure out the username using 'whoami' " + ret.getStderr()); return null; } }
FileTools { public static String whoAmI() { ArrayList<String> theCommand = new ArrayList<>(); theCommand.add("bash"); theCommand.add("-lc"); theCommand.add("whoami"); ReturnValue ret = RunTools.runCommand(theCommand.toArray(new String[theCommand.size()])); if (ret.getExitStatus() == ReturnValue.SUCCESS) { String stdout = ret.getStdout(); stdout = stdout.trim(); return (stdout); } else { Log.error("Can't figure out the username using 'whoami' " + ret.getStderr()); return null; } } }
FileTools { public static String whoAmI() { ArrayList<String> theCommand = new ArrayList<>(); theCommand.add("bash"); theCommand.add("-lc"); theCommand.add("whoami"); ReturnValue ret = RunTools.runCommand(theCommand.toArray(new String[theCommand.size()])); if (ret.getExitStatus() == ReturnValue.SUCCESS) { String stdout = ret.getStdout(); stdout = stdout.trim(); return (stdout); } else { Log.error("Can't figure out the username using 'whoami' " + ret.getStderr()); return null; } }  }
FileTools { public static String whoAmI() { ArrayList<String> theCommand = new ArrayList<>(); theCommand.add("bash"); theCommand.add("-lc"); theCommand.add("whoami"); ReturnValue ret = RunTools.runCommand(theCommand.toArray(new String[theCommand.size()])); if (ret.getExitStatus() == ReturnValue.SUCCESS) { String stdout = ret.getStdout(); stdout = stdout.trim(); return (stdout); } else { Log.error("Can't figure out the username using 'whoami' " + ret.getStderr()); return null; } }  static String byte2HexString(byte[] b); static ReturnValue verifyFile(File file); static ReturnValue dirPathExistsAndWritable(File file); static ReturnValue dirPathExistsAndReadable(File file); static ReturnValue fileExistsAndReadable(File file); static ReturnValue fileExistsAndNotEmpty(File file); static File createTempDirectory(File parentDir); static File createDirectoryWithUniqueName(File parentDir, String prefix); static File createFileWithUniqueName(File parentDir, String prefix); static boolean deleteDirectoryRecursive(File path); static boolean zipDirectoryRecursive(File path, File zipFileName, boolean compress); static boolean unzipFile(File path, File outputDir); static void listFilesRecursive(File path, List<File> filesArray); static Map<String, String> getKeyValueFromFile(String path); static boolean isFileOwner(String path); static String whoAmI(); static String getFilename(String filePath); static String getFilePath(String filePath); static LocalhostPair getLocalhost(OptionSet options); }
FileTools { public static String whoAmI() { ArrayList<String> theCommand = new ArrayList<>(); theCommand.add("bash"); theCommand.add("-lc"); theCommand.add("whoami"); ReturnValue ret = RunTools.runCommand(theCommand.toArray(new String[theCommand.size()])); if (ret.getExitStatus() == ReturnValue.SUCCESS) { String stdout = ret.getStdout(); stdout = stdout.trim(); return (stdout); } else { Log.error("Can't figure out the username using 'whoami' " + ret.getStderr()); return null; } }  static String byte2HexString(byte[] b); static ReturnValue verifyFile(File file); static ReturnValue dirPathExistsAndWritable(File file); static ReturnValue dirPathExistsAndReadable(File file); static ReturnValue fileExistsAndReadable(File file); static ReturnValue fileExistsAndNotEmpty(File file); static File createTempDirectory(File parentDir); static File createDirectoryWithUniqueName(File parentDir, String prefix); static File createFileWithUniqueName(File parentDir, String prefix); static boolean deleteDirectoryRecursive(File path); static boolean zipDirectoryRecursive(File path, File zipFileName, boolean compress); static boolean unzipFile(File path, File outputDir); static void listFilesRecursive(File path, List<File> filesArray); static Map<String, String> getKeyValueFromFile(String path); static boolean isFileOwner(String path); static String whoAmI(); static String getFilename(String filePath); static String getFilePath(String filePath); static LocalhostPair getLocalhost(OptionSet options); static final String FORCE_HOST; }