/** * <pre> * rsync source destination * rsync source [user@]hostname:destination * rsync [user@]hostname:source destination * </pre> */ public static final int rsync(String source, String destination) { return rsync(null, source, destination); }
/** * <pre> * rsync [options] source destination * </pre> * * Where <code>source</code> and <code>destination</code> are both directories on the local file system. <code>source</code> must already exist. <code>destination</code> will * be created if it does not exist. */ public static final int rsyncdirs(List<String> options, File source, File destination) { String sourcePath = validateRsyncSourceDir(source); String destinationPath = validateRsyncDestinationDir(destination); return rsyncdirs(options, sourcePath, destinationPath); }
/** * <pre> * scp source destination * </pre> * * Where both <code>source</code> and <code>destination</code> are in the format * * <pre> * [[user@]host:]file * </pre> */ public static final int scp(String source, String destination) { return scp(null, source, destination); }
/** * <pre> * rsync [options] [user@]hostname:source destination * </pre> * * Where <code>destination</code> is a directory on the local file system. <code>destination</code> will be created if it does not exist */ public static final int rsyncdirs(List<String> options, String source, File destination) { String destinationPath = validateRsyncDestinationDir(destination); return rsyncdirs(options, source, destinationPath); }
/** * <pre> * rsync [options] source [user@]hostname:destination * </pre> * * Where <code>source</code> is a directory on the local file system. <code>source</code> must already exist. */ public static final int rsync(List<String> options, File source, String destination) { String sourcePath = validateRsyncSourceDir(source); return rsyncdirs(options, sourcePath, destination); }
/** * <pre> * ssh hostname command * </pre> */ public static final int ssh(String hostname, String command) { return ssh(null, null, hostname, command); }
/** * <pre> * rsync [options] source destination * rsync [options] source [user@]hostname:destination * rsync [options] [user@]hostname:source destination * </pre> * * Always add a trailing slash to source when sync'ing directories.<br> * This forces rsync to behave like <code>cp</code> * * <pre> * cp -R /tmp/foo/bar /tmp/xyz - creates files in /tmp/xyz * rsync /tmp/foo/bar/ /tmp/xyz - creates files in /tmp/xyz * * rsync /tmp/foo/bar /tmp/xyz - creates files in /tmp/xyz/bar * </pre> */ public static final int rsyncdirs(List<String> options, String source, String destination) { List<String> rsyncDirOptions = getRsyncDirOptions(options); // Make sure source always has a trailing slash String trailingSlashSource = StringUtils.endsWith(source, FORWARD_SLASH) ? source : source + FORWARD_SLASH; return rsync(rsyncDirOptions, trailingSlashSource, destination); }
/** * <pre> * ssh hostname chown owner:group file * </pre> */ public static final int sshchown(String hostname, String owner, String group, String file) { return sshchown(null, null, hostname, owner, group, file); }
/** * <pre> * ssh [user@]hostname mkdir -p directory * </pre> */ public static final int sshmkdir(String user, String hostname, String path) { return sshmkdir(null, user, hostname, path); }
/** * <pre> * ssh [user@]hostname chown -R owner:group file * </pre> */ public static final int sshchownr(String user, String hostname, String owner, String group, String file) { return sshchownr(null, user, hostname, owner, group, file); }
/** * <pre> * ssh [args] [user@]hostname command * </pre> */ public static final int ssh(List<String> args, String user, String hostname, String command) { Assert.notNull(hostname); Assert.notNull(command); List<String> arguments = new ArrayList<String>(); arguments.addAll(CollectionUtils.toEmptyList(args)); if (!StringUtils.isBlank(user)) { arguments.add(user + "@" + hostname); } else { arguments.add(hostname); } arguments.add(command); Commandline cl = new Commandline(); cl.setExecutable(SSH); cl.addArguments(CollectionUtils.toStringArray(arguments)); return execute(cl); }
/** * <pre> * ssh [user@]hostname chmod mode file * </pre> */ public static final int sshchmod(String user, String hostname, String mode, String file) { return sshchmod(null, user, hostname, mode, file); }
/** * <pre> * rsync [options] source destination * rsync [options] source [user@]hostname:destination * rsync [options] [user@]hostname:source destination * </pre> */ public static final int rsyncdirs(String source, String destination) { return rsyncdirs(null, source, destination); }
/** * <pre> * rsync [user@]hostname:source destination * </pre> * * Where <code>destination</code> is a directory on the local file system. <code>destination</code> will be created if it does not exist */ public static final int rsyncdirs(String source, File destination) { String destinationPath = validateRsyncDestinationDir(destination); return rsyncdirs(null, source, destinationPath); }
/** * <pre> * ssh [args] hostname command * </pre> */ public static final int ssh(List<String> args, String hostname, String command) { return ssh(args, null, hostname, command); }
/** * <pre> * rsync source [user@]hostname:destination * </pre> * * Where <code>source</code> is a directory on the local file system. <code>source</code> must already exist. */ public static final int rsyncdirs(File source, String destination) { String sourcePath = validateRsyncSourceDir(source); return rsyncdirs(null, sourcePath, destination); }
/** * <pre> * ssh [args] hostname chown owner:group file * </pre> */ public static final int sshchown(List<String> args, String hostname, String owner, String group, String file) { return sshchown(args, null, hostname, null, owner, group, file); }
/** * <pre> * ssh hostname mkdir -p directory * </pre> */ public static final int sshmkdir(String hostname, String path) { return sshmkdir(null, null, hostname, path); }
/** * <pre> * ssh [args] hostname chown -R owner:group file * </pre> */ public static final int sshchownr(List<String> args, String hostname, String owner, String group, String file) { return sshchownr(args, null, hostname, owner, group, file); }
/** * <pre> * rsync [options] source destination * rsync [options] source [user@]hostname:destination * rsync [options] [user@]hostname:source destination * </pre> */ public static final int rsync(List<String> options, String source, String destination) { Assert.notNull(source); Assert.notNull(destination); List<String> arguments = new ArrayList<String>(); arguments.addAll(CollectionUtils.toEmptyList(options)); arguments.add(source); arguments.add(destination); Commandline cl = new Commandline(); cl.setExecutable(RSYNC); cl.addArguments(CollectionUtils.toStringArray(arguments)); return execute(cl); }