Revision [583]
This is an old revision of CommandsPosix made by DavidLee on 2009-05-30 06:15:50.
Posix Commands
The following commands are built in to xmlsh, but need to be imported. They are not imported by default because they provide a simpler (less feature-full) implementation of common posix commands which are likely to exist in the environment. On Linux, Unix and Mac/OS these will already exist in /bin or /usr/bin. On Windows they will exist if you have cygwin or other unix compatibility software installed.
Importing
To use the Posix commands you need to import them into either the global namespace or a local namespace.Its recommended that you use a local namespace so that you still have access to the system commands of the same name.
To import into the posix namespace
import commands posix=posix
To import into the global namespace
import commands posix
Advantages / Disadvantages
You may want to use these commands even if they exist in the environment for the following reasons- They are very fast.
- These commands are run in the shell's JVM and do not require starting a subprocess.
- No dependancy on environment
- You can use these commands to write scripts that do not depend on them existing in the environment. The test cases use these commands so they can run on Windows without presuming you have cygwin installed.
- They are less feature-full then the coresponsing OS commands.
- They are not as mature, these commands are a simple implementation using core java methods and may not be as roboust as the OS commands.
Commands
- cp - copy one or more files
- cat - copy or concatenate files
- mkdir - Create directories
- mv - Move/Rename files
- rm - Remove/Delete files
- rmdir - Remove/Delete directories
- [[CommandSleep sleep] - Delay execution
- touch - create and update timestamp of a file
- ls - list files in a directory