eXpOS Shell specification

The eXpOS shell program is designed to repeatedly ask for user commands and execute the command specified by the user. There are two types of commands that the user can input to the shell:

Built in Shell commands

Built in shell commands are 1) Newusr (to create a new user), 2) Remusr (to remove a user), 3) Setpwd (set the password of a user), 4) Getuid (to get the user-id of the currently logged in user), 5) Getuname (to get the username of the currently logged in user), 6) Logout (logout the current user) and 7) Shutdown (to shutdown the system after committing back the memory copies of all disk data structures into the disk). To execute the system call for the corresponding shell command - eg : For the system call Newusr, enter the string "Newusr" (without quotes) from the console.

Upon receipt of one of these commands, the shell directly asks the user for the input arguments for the corresponding system call (for example - setpwd requires the username and the new password to be entered) and invokes the corresponding system call directly to execute the command. In all the above cases except logout and shutdown, the shell continues to ask the user for the next command after execution of the system call. If the executed system call for the input command is not successful, then shell simply prints "BAD COMMAND".

Executable commands/filenames

An executable command is essentially the name of an executable file. In such case, shell first spawns a child using the Fork system call and the parent (shell) waits for the child to do an Exit upon completion of command execution. The child runs the input file using the Exec system call. If Exec fails, then child prints “BAD COMMAND” and executes the Exit system call to activate the shell again.

eXpOS specifies that some standard executable programs called (system utilities) are supplied to the user along with the OS implementation. These programs essentially help the user to manipulate files using the shell. They are listed below:

  • 1. List all files

    • Command : ls.xsm
    • Input : -
    • Semantics : Displays the names of all the files present in the disk.
  • 2. Remove a File

    • Command : rm.xsm
    • Input : filename
    • Semantics : Removes a data file filename from the disk.
  • 3. Copy content of one file to another

    • Command : cp.xsm
    • Input : filename1, filename2
    • Semantics : Copies the word to word data from a file filename1 to the file filename2. (filename1 can be only data or root file.)
  • 4. Print the content of a file

    • Command : cat.xsm
    • Input : filename
    • Semantics : Displays the content of the file filename.
  • 5. List all users

    • Command : lu.xsm
    • Input : -
    • Semantics : Displays the names of all the users in the system.
  • 6. Remove all files owned by a user

    • Command : ru.xsm
    • Input : username
    • Semantics : Deletes all the data files owned by the user with name username. (Typically it is executed from the root user to delete all the files owned by a user before removing the user from the system.)

A sample shell implementation is given here. The details of implementation of system utilities are left to the OS programmer. Since eXpOS ABI does not support command line arguments, these programs may need to ask the user for inputs (like filename in the case of the cat command) using the Read system call.

The eXpOS specification stipulates that shell always executes from the context of the currently logged in user. The shell is spawned by the login process.