com.izforge.izpack.util.os.unix
Class UnixHelper

java.lang.Object
  extended by com.izforge.izpack.util.os.unix.UnixHelper

public class UnixHelper
extends java.lang.Object

Helper Methods for unix-systems and derived.

Version:
$Revision: 2163 $
Author:
marc.eppelmann@reddot.de

Field Summary
static java.lang.String VERSION
           
static java.lang.String whichCommand
          whichCommand = "/usr/bin/which" or /bin/which
 
Constructor Summary
UnixHelper()
           
 
Method Summary
static java.lang.String getCpCommand()
          Gets the absolute path of the cp (Copy) command.
static java.lang.String getCustomCommand(java.lang.String aCommand)
          Gets the absolute Pathe to the given custom command.
static java.util.ArrayList<java.lang.String> getEtcPasswdArray()
          Get the lines from /etc/passwd as Array
static java.lang.String getRmCommand()
          Gets the absolute Pathe to the rm (Remove) Command.
static java.lang.String getSuCommand()
          Gets the absolute path to the su (SuperUser) command.
static java.lang.String getWhichCommand()
          Gets the absolute path of the which command.
static java.lang.String getYpCatCommand()
          Gets the absolute Pathe to the ypcat (YellowPage/NIS Cat) Command.
static java.util.ArrayList<java.lang.String> getYpPasswdArray()
          Get the YelloyPages (NIS) Users lines from ypcat passwd as Array.
static boolean kdeIsInstalled()
          Test if KDE is installed.
static void main(java.lang.String[] args)
          Standalone Test Main Method call with : > java -cp ..
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

whichCommand

public static java.lang.String whichCommand
whichCommand = "/usr/bin/which" or /bin/which


VERSION

public static final java.lang.String VERSION
See Also:
Constant Field Values
Constructor Detail

UnixHelper

public UnixHelper()
Method Detail

getEtcPasswdArray

public static java.util.ArrayList<java.lang.String> getEtcPasswdArray()
Get the lines from /etc/passwd as Array

Returns:
the /etc/passwd as String ArrayList

getYpPasswdArray

public static java.util.ArrayList<java.lang.String> getYpPasswdArray()
Get the YelloyPages (NIS) Users lines from ypcat passwd as Array. Ypcat passwd's output has the same format as the the local /etc/passwd. Because there can be thousands of yp-users and this query is net-based, this is a candidate for a token-based optimization.

Returns:
the /etc/passwd as String ArrayList

kdeIsInstalled

public static boolean kdeIsInstalled()
Test if KDE is installed. This is done by $>/usr/bin/env kwin --version This assumes that kwin, the window Manager, as part of the kde-base package is already installed. If this returns with 0 kwin resp. kde means to be installed,

Returns:
true if kde is installed otherwise false.

getWhichCommand

public static java.lang.String getWhichCommand()
Gets the absolute path of the which command. This is necessary, because the command is located at /bin on linux but in /usr/bin on Sun Solaris.

Returns:
/bin/which on linux /usr/bin/which on solaris

getCpCommand

public static java.lang.String getCpCommand()
Gets the absolute path of the cp (Copy) command. This is necessary, because the command is located at /bin on linux but in /usr/bin on Sun Solaris.

Returns:
/bin/cp on linux /usr/bin/cp on solaris

getSuCommand

public static java.lang.String getSuCommand()
Gets the absolute path to the su (SuperUser) command. This is necessary, because the command is located at /bin on linux but in /usr/bin on Sun Solaris.

Returns:
/bin/su on linux /usr/bin/su on solaris

getRmCommand

public static java.lang.String getRmCommand()
Gets the absolute Pathe to the rm (Remove) Command. This is necessary, because the command is located at /bin on linux but in /usr/bin on Sun Solaris.

Returns:
/bin/rm on linux /usr/bin/rm on solaris

getYpCatCommand

public static java.lang.String getYpCatCommand()
Gets the absolute Pathe to the ypcat (YellowPage/NIS Cat) Command. This is necessary, because the command is located at /bin on linux but in /usr/bin on Sun Solaris.

Returns:
/bin/ypcat on linux /usr/bin/ypcat on solaris

getCustomCommand

public static java.lang.String getCustomCommand(java.lang.String aCommand)
Gets the absolute Pathe to the given custom command. This is necessary, because the command may be located at /bin on linux but in /usr/bin on Sun Solaris. Which can locate it in your $PATH for you.

Parameters:
aCommand - a Custom Command
Returns:
/bin/aCommand on linux /usr/bin/aCommand on solaris

main

public static void main(java.lang.String[] args)
Standalone Test Main Method call with : > java -cp ../_build com.izforge.izpack.util.os.unix.UnixHelper

Parameters:
args - commandline args