Wiki source for CommandsPosix


Show raw source

=====Posix Commands=====

The following commands are built in to xmlsh, but need to be [[CommandImport 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 [[CommandImport 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 p namespace prefix
%%
import commands p=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.
- Consistant with xmlsh internal environment model
- Since these commands are implemented using the internal API they will produce results more consistant with the internal model. For example the cygwin "pwd" command can give different results then the xmlsh posix "pwd" command due to cygwin's differing model of the filesystem.

You may want to **avoid **these commands for the following reasons
- 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.
- There are some things these commands cannot do which the native OS commands can, due to being based (limited by) java API's. For example the [[CommandChmod chmod]] command cannot set group permissions or setuid modes.
- The options are not as rich as the equivalent OS commands and may not be identical.

It is recommended that you import the Posix commands using a prefix rather then into the global namespace otherwise you will be unable to access the OS commands of the same name without using their full path.


====Commands====

- [[CommandBase64 base64]] - ""Base64"" encode/decode
- [[CommandCat cat]] - copy or concatenate files
- [[CommandChmod chmod]] - Change file permissions
- [[CommandCp cp]] - copy one or more files
- [[CommandLs ls]] - list files in a directory
- [[CommandMkdir mkdir]] - Create directories
- [[CommandMktemp mktemp]] - Create a temporary file or directory
- [[CommandMore more]] - Simple Paginator
- [[CommandMv mv]] - Move/Rename files
- [[CommandRm rm]] - Remove/Delete files
- [[CommandRmdir rmdir]] - Remove/Delete directories
- [[CommandSleep sleep]] - Delay execution
- [[CommandTee tee]] - Read from standard input and write to standard output and files
- [[CommandTouch touch]] - Create and update timestamp of a file
- [[CommandPwd pwd]] - print current working directory
- [[CommandWc wc]] - word count

----
[[Commands]]
[[CategoryCommands]]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki