One of the most significant parts of A2osX is its shell which can perform both interactive and scripted tasks. With the interactive part of the shell you can perform many common and complex tasks using both built-in (native or internal to shell) and external (BINs or executables) commands. Internal commands include CD (change directory), MD (make directory), PWD, DATE, etc. External commands include CP (copy), RM (remove), CAT (display file contents), TELNET, etc.
It should be noted, that it is possible to create and execute short scripts right on the interactive command line (these are run once and not saved like true scripts). An example
```
FOR FILE IN `LS -C CT*`; CAT ${FILE}; NEXT
```
In this example, the system will generate a list of files found in the current directory that match the CT* wild card and perform the CAT operation on each. The semicolons act as a line separator allowing you to type in multiple commands, or short scripts on a single line, to execute as a script.
This Developers Guide will cover the basic operation of the interactive shell, the available commands as well as creating and using complex scripts that can be run by the shell.
The default A2osX Shell, ./BIN/SH, is an A2osX external command program like many others included with A2osX. It is probably the most complex and capable, as suggested by its size compared to other commands (7K vs 1K for TELNET), and is the primary tool for interacting with the A2osX system. The SH shell is based somewhat on the Linux BASH shell, to the extend possible on an 8-bit machine. Alternative shells are planned for the future and will be announced as they become available.
As the primary mechanism for working with A2osX, the SH shell is launched automatically when you log into A2osX. In the case where no ./ETC/PASSWD file is present, A2osX automatically logs you in as the ROOT user. When a user login occurs and SH is launched, it looks for a file called PROFILE in the users HOME directory and if found executes that script, so the information below on writing scripts applies to the PROFILE file.
To interact with the A2osX shell, you type commands at the presented prompt, which ends with a **$** character. The prompt usually includes your current working directory such as **/FULLBOOT/ROOT/$**. You can change the prompt by changing the **$PS1** variable (see below). At the **$** you can enter any of the valid internal shell commands or an external program name. For external programs, A2osX will search in the current directory and then in the directories specified in the **$PATH** variable.
The 32-bit int data type can hold integer values in the range of −2,147,483,648 to 2,147,483,647. If you add to or subtract from INTs that would cause a RANGE error, you actually get a result that wraps around the range, so if you add 1 to 2,147,483,647 you will get −2,147,483,648.
Strings can be up to 255 characters in length. Note, like INTs, if you try to store more then 255 chars in a string, you get the same wraparound affect where the first 255 chars are tossed out the string is set to the remaining chars, so if you concatenate 3 strings of 100 chars the resulting string will be the last 45 chars of the 3rd original string.
| DATE | Working | %a : Abbreviated weekday name : Thu <br> %A : Full weekday name : Thursday <br> %b : Abbreviated month name : Aug <br> %B : Full month name : August <br> %d : Day of the month, zero-padded (01-31) <br> %H : Hour in 24h format (00-23) 14 <br> %I : Hour in 12h format (01-12) 02 <br> %m : Month as a decimal number (01-12) 08 <br> %M : Minute (00-59) 55 <br> %p : AM or PM designation PM <br> %S : Second (00-61) 02 <br> %w : Weekday as a decimal number with Sunday as 0 (0-6) <br> %y : Year, last two digits (00-99) <br> %Y : Year four digits 2001 |