org.kuali.common.util
Class UnixUtils

java.lang.Object
  extended by org.kuali.common.util.UnixUtils

public class UnixUtils
extends Object

Execute Unix utilities using java.


Field Summary
static int SUCCESS
           
 
Constructor Summary
UnixUtils()
           
 
Method Summary
static int execute(org.codehaus.plexus.util.cli.Commandline cl)
           
static String getLocation(String user, String hostname, String filename)
           
protected static List<String> getRsyncDirOptions(List<String> options)
          Return a list containing the options --recursive, --archive, and --delete as the first 3 elements, with additional options coming after.
static int rsync(List<String> options, File source, String destination)
           rsync [options] source [user@]hostname:destination
static int rsync(List<String> options, String source, String destination)
           rsync [options] source destination rsync [options] source [user@]hostname:destination rsync [options] [user@]hostname:source destination
static int rsync(String source, String destination)
           rsync source destination rsync source [user@]hostname:destination rsync [user@]hostname:source destination
static int rsyncdirs(File source, File destination)
           rsync source destination
static int rsyncdirs(File source, String destination)
           rsync source [user@]hostname:destination
static int rsyncdirs(List<String> options, File source, File destination)
           rsync [options] source destination
static int rsyncdirs(List<String> options, String source, File destination)
           rsync [options] [user@]hostname:source destination
static int rsyncdirs(List<String> options, String source, String destination)
           rsync [options] source destination rsync [options] source [user@]hostname:destination rsync [options] [user@]hostname:source destination
static int rsyncdirs(String source, File destination)
           rsync [user@]hostname:source destination
static int rsyncdirs(String source, String destination)
           rsync [options] source destination rsync [options] source [user@]hostname:destination rsync [options] [user@]hostname:source destination
static int scp(File source, String destination)
           scp source destination
static int scp(List<String> args, File source, String destination)
           scp [args] source destination
static int scp(List<String> args, String source, File destination)
           scp [args] source destination
static int scp(List<String> args, String source, String destination)
           scp [args] source destination
static int scp(String source, File destination)
           scp source destination
static int scp(String source, String destination)
           scp source destination
static int ssh(List<String> args, String hostname, String command)
           ssh [args] hostname command
static int ssh(List<String> args, String user, String hostname, String command)
           ssh [args] [user@]hostname command
static int ssh(String hostname, String command)
           ssh hostname command
static int ssh(String user, String hostname, String command)
           ssh [user@]hostname command
static int sshchmod(List<String> args, String user, String hostname, String mode, String path)
           ssh [args] [user@]hostname chmod mode file
static int sshchmod(String user, String hostname, String mode, String file)
           ssh [user@]hostname chmod mode file
static int sshchown(List<String> args, String user, String hostname, List<String> options, String owner, String group, String file)
           ssh [args] [user@]hostname chown [chownargs] owner:group file
static int sshchown(List<String> args, String hostname, String owner, String group, String file)
           ssh [args] hostname chown owner:group file
static int sshchown(List<String> args, String user, String hostname, String owner, String group, String file)
           ssh [args] [user@]hostname chown owner:group file
static int sshchown(String hostname, String owner, String group, String file)
           ssh hostname chown owner:group file
static int sshchown(String user, String hostname, String owner, String group, String file)
           ssh [user@]hostname chown owner:group file
static int sshchownr(List<String> args, String hostname, String owner, String group, String file)
           ssh [args] hostname chown -R owner:group file
static int sshchownr(List<String> args, String user, String hostname, String owner, String group, String file)
           ssh [args] [user@]hostname chown -R owner:group file
static int sshchownr(String hostname, String owner, String group, String file)
           ssh hostname chown -R owner:group file
static int sshchownr(String user, String hostname, String owner, String group, String file)
           ssh [user@]hostname chown -R owner:group file
static int sshmkdir(List<String> args, String hostname, String path)
           ssh [args] hostname mkdir -p directory
static int sshmkdir(List<String> args, String user, String hostname, String path)
           ssh [args] [user@]hostname mkdir -p directory
static int sshmkdir(String hostname, String path)
           ssh hostname mkdir -p directory
static int sshmkdir(String user, String hostname, String path)
           ssh [user@]hostname mkdir -p directory
static int sshrm(List<String> args, String hostname, List<String> paths)
           ssh [args] hostname rm -rf file ...
static int sshrm(List<String> args, String hostname, String file)
           ssh [args] hostname rm -rf file
static int sshrm(List<String> args, String user, String hostname, List<String> paths)
           ssh [args] [user@]hostname rm -rf file ...
static int sshrm(List<String> args, String user, String hostname, List<String> options, List<String> paths)
           ssh [args] [user@]hostname rm [rmargs] file ...
static int sshrm(List<String> args, String user, String hostname, String file)
           ssh [args] [user@]hostname rm -rf file
static int sshrm(String hostname, List<String> paths)
           ssh hostname rm -rf file ...
static int sshrm(String hostname, String file)
           ssh hostname rm -rf file
static int sshrm(String user, String hostname, List<String> paths)
           ssh [user@]hostname rm -rf file ...
static int sshrm(String user, String hostname, String file)
           ssh [user@]hostname rm -rf file
static int sshsu(List<String> args, String hostname, String login, String command)
           ssh [args] hostname su - login command
static int sshsu(List<String> args, String user, String hostname, String login, String command)
           ssh [args] [user@]hostname su - login command
static int sshsu(String hostname, String login, String command)
           ssh hostname su - login command
static int sshsu(String user, String hostname, String login, String command)
           ssh [user@]hostname su - login command
static void validate(int exitValue, String message)
           
static void validate(int exitValue, String message, Mode mode)
           
protected static String validateRsyncDestinationDir(File dir)
           
protected static String validateRsyncSourceDir(File dir)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SUCCESS

public static final int SUCCESS
See Also:
Constant Field Values
Constructor Detail

UnixUtils

public UnixUtils()
Method Detail

rsyncdirs

public static final int rsyncdirs(File source,
                                  File destination)
  rsync source destination
 
Where source and destination are both directories on the local file system. source must already exist. destination will be created if it does not exist.


rsyncdirs

public static final int rsyncdirs(File source,
                                  String destination)
  rsync source [user@]hostname:destination
 
Where source is a directory on the local file system. source must already exist.


rsyncdirs

public static final int rsyncdirs(String source,
                                  File destination)
  rsync [user@]hostname:source destination
 
Where destination is a directory on the local file system. destination will be created if it does not exist


rsyncdirs

public static final int rsyncdirs(List<String> options,
                                  File source,
                                  File destination)
  rsync [options] source destination
 
Where source and destination are both directories on the local file system. source must already exist. destination will be created if it does not exist.


rsync

public static final int rsync(List<String> options,
                              File source,
                              String destination)
  rsync [options] source [user@]hostname:destination
 
Where source is a directory on the local file system. source must already exist.


rsyncdirs

public static final int rsyncdirs(List<String> options,
                                  String source,
                                  File destination)
  rsync [options] [user@]hostname:source destination
 
Where destination is a directory on the local file system. destination will be created if it does not exist


rsyncdirs

public static final int rsyncdirs(List<String> options,
                                  String source,
                                  String destination)
  rsync [options] source destination
  rsync [options] source [user@]hostname:destination
  rsync [options] [user@]hostname:source destination
 
Always add a trailing slash to source when sync'ing directories.
This forces rsync to behave like cp
 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
 


rsyncdirs

public static final int rsyncdirs(String source,
                                  String destination)
  rsync [options] source destination
  rsync [options] source [user@]hostname:destination
  rsync [options] [user@]hostname:source destination
 


rsync

public static final int rsync(String source,
                              String destination)
  rsync source destination
  rsync source [user@]hostname:destination
  rsync [user@]hostname:source destination
 


rsync

public static final int rsync(List<String> options,
                              String source,
                              String destination)
  rsync [options] source destination
  rsync [options] source [user@]hostname:destination
  rsync [options] [user@]hostname:source destination
 


sshchown

public static final int sshchown(List<String> args,
                                 String user,
                                 String hostname,
                                 List<String> options,
                                 String owner,
                                 String group,
                                 String file)
 ssh [args] [user@]hostname chown [chownargs] owner:group file
 


sshchownr

public static final int sshchownr(String hostname,
                                  String owner,
                                  String group,
                                  String file)
 ssh hostname chown -R owner:group file
 


sshchownr

public static final int sshchownr(String user,
                                  String hostname,
                                  String owner,
                                  String group,
                                  String file)
 ssh [user@]hostname chown -R owner:group file
 


sshchownr

public static final int sshchownr(List<String> args,
                                  String hostname,
                                  String owner,
                                  String group,
                                  String file)
 ssh [args] hostname chown -R owner:group file
 


sshchownr

public static final int sshchownr(List<String> args,
                                  String user,
                                  String hostname,
                                  String owner,
                                  String group,
                                  String file)
 ssh [args] [user@]hostname chown -R owner:group file
 


sshchown

public static final int sshchown(List<String> args,
                                 String hostname,
                                 String owner,
                                 String group,
                                 String file)
 ssh [args] hostname chown owner:group file
 


sshchown

public static final int sshchown(List<String> args,
                                 String user,
                                 String hostname,
                                 String owner,
                                 String group,
                                 String file)
 ssh [args] [user@]hostname chown owner:group file
 


sshchown

public static final int sshchown(String user,
                                 String hostname,
                                 String owner,
                                 String group,
                                 String file)
 ssh [user@]hostname chown owner:group file
 


sshchown

public static final int sshchown(String hostname,
                                 String owner,
                                 String group,
                                 String file)
 ssh hostname chown owner:group file
 


sshrm

public static final int sshrm(String hostname,
                              String file)
 ssh hostname rm -rf file
 


sshrm

public static final int sshrm(String user,
                              String hostname,
                              String file)
 ssh [user@]hostname rm -rf file
 


sshrm

public static final int sshrm(List<String> args,
                              String hostname,
                              String file)
 ssh [args] hostname rm -rf file
 


sshrm

public static final int sshrm(List<String> args,
                              String user,
                              String hostname,
                              String file)
 ssh [args] [user@]hostname rm -rf file
 


sshrm

public static final int sshrm(String hostname,
                              List<String> paths)
 ssh hostname rm -rf file ...
 


sshrm

public static final int sshrm(String user,
                              String hostname,
                              List<String> paths)
 ssh [user@]hostname rm -rf file ...
 


sshrm

public static final int sshrm(List<String> args,
                              String hostname,
                              List<String> paths)
 ssh [args] hostname rm -rf file ...
 


sshrm

public static final int sshrm(List<String> args,
                              String user,
                              String hostname,
                              List<String> paths)
 ssh [args] [user@]hostname rm -rf file ...
 


sshrm

public static final int sshrm(List<String> args,
                              String user,
                              String hostname,
                              List<String> options,
                              List<String> paths)
 ssh [args] [user@]hostname rm [rmargs] file ...
 


sshchmod

public static final int sshchmod(List<String> args,
                                 String user,
                                 String hostname,
                                 String mode,
                                 String path)
 ssh [args] [user@]hostname chmod mode file
 


sshchmod

public static final int sshchmod(String user,
                                 String hostname,
                                 String mode,
                                 String file)
 ssh [user@]hostname chmod mode file
 


sshmkdir

public static final int sshmkdir(String user,
                                 String hostname,
                                 String path)
 ssh [user@]hostname mkdir -p directory
 


sshmkdir

public static final int sshmkdir(List<String> args,
                                 String user,
                                 String hostname,
                                 String path)
 ssh [args] [user@]hostname mkdir -p directory
 


sshmkdir

public static final int sshmkdir(String hostname,
                                 String path)
 ssh hostname mkdir -p directory
 


sshmkdir

public static final int sshmkdir(List<String> args,
                                 String hostname,
                                 String path)
 ssh [args] hostname mkdir -p directory
 


sshsu

public static final int sshsu(String hostname,
                              String login,
                              String command)
 ssh hostname su - login command
 


sshsu

public static final int sshsu(List<String> args,
                              String hostname,
                              String login,
                              String command)
 ssh [args] hostname su - login command
 


sshsu

public static final int sshsu(String user,
                              String hostname,
                              String login,
                              String command)
 ssh [user@]hostname su - login command
 


sshsu

public static final int sshsu(List<String> args,
                              String user,
                              String hostname,
                              String login,
                              String command)
 ssh [args] [user@]hostname su - login command
 


ssh

public static final int ssh(String hostname,
                            String command)
 ssh hostname command
 


ssh

public static final int ssh(String user,
                            String hostname,
                            String command)
 ssh [user@]hostname command
 


ssh

public static final int ssh(List<String> args,
                            String hostname,
                            String command)
 ssh [args] hostname command
 


ssh

public static final int ssh(List<String> args,
                            String user,
                            String hostname,
                            String command)
 ssh [args] [user@]hostname command
 


scp

public static final int scp(String source,
                            String destination)
 scp source destination
 
Where both source and destination are in the format
 [[user@]host:]file
 


scp

public static final int scp(List<String> args,
                            String source,
                            String destination)
 scp [args] source destination
 
Where both source and destination are in the format
 [[user@]host:]file
 


scp

public static final int scp(List<String> args,
                            File source,
                            String destination)
 scp [args] source destination
 
Where source is a file on the local file system and destination is in the format
 [[user@]host:]file
 


scp

public static final int scp(List<String> args,
                            String source,
                            File destination)
 scp [args] source destination
 
Where destination is a file on the local file system and source is in the format
 [[user@]host:]file
 


scp

public static final int scp(File source,
                            String destination)
 scp source destination
 
Where source is a file on the local file system and destination is in the format
 [[user@]host:]file
 


scp

public static final int scp(String source,
                            File destination)
 scp source destination
 
Where destination is a file on the local file system and source is in the format
 [[user@]host:]file
 


validate

public static final void validate(int exitValue,
                                  String message,
                                  Mode mode)

validate

public static final void validate(int exitValue,
                                  String message)

execute

public static final int execute(org.codehaus.plexus.util.cli.Commandline cl)

getLocation

public static final String getLocation(String user,
                                       String hostname,
                                       String filename)

validateRsyncSourceDir

protected static final String validateRsyncSourceDir(File dir)

validateRsyncDestinationDir

protected static final String validateRsyncDestinationDir(File dir)

getRsyncDirOptions

protected static final List<String> getRsyncDirOptions(List<String> options)
Return a list containing the options --recursive, --archive, and --delete as the first 3 elements, with additional options coming after.



Copyright © 2010-2013 The Kuali Foundation. All Rights Reserved.