A user who is logged into a machine can use the who command to determine what users are logged in on that machine. However, the process of repeatedly logging in and running who on various machines until an empty one is found is tedious. Also, some of the machines may be booted into Windows, or shut down, further complicating the problem. This project is to write a shell script that automates this process.
One feature that distinquished UNIX from its predecessor operating systems was its provision of the shell, which provides much of the UNIX user-interface, plus a built-in shell command language. Over the years, various shells have been created for UNIX, including:
sh is the original UNIX shell, and is called the bourne shell after Steve Bourne, its creator. While later shells such as csh, ksh, tcsh, and bash extended the features of the bourne shell, it is still available on every UNIX system. Bourne shell scripts are thus very portable across different UNIX platforms.
To create a shell script, you simply store a sequence of shell commands in a file, and then make this file executable (using the system chmod command). Typing the name of the file then executes the commands within it.
The commands that can appear in a shell script include both
For safety, shell scripts should be executed in a shell that is distinct from the login shell. For the bourne shell, this is accomplished by making
#!/bin/shthe first line of the shell script. The effect of this line is to make the system
Your assignment is to write a bourne shell script that when executed, prints out a list of the Ulab workstations, indicating those that are booted into Linux and are unoccupied, those that are are booted into Linux but are occupied, those that are booted into Windows, those that are shut down, and any other information you think might be useful.
You can find tutorials for bourne shell scripting on the web -- use your favorite search engine to find them, if necessary.
Shell-script comments begin with the # symbol and end at the end of a line. Your script should include full documentation and should use white space (esp. indentation) to reflect its structure.
Your script should be reasonably efficient, and should "clean up" after itself as necessary, so as to leave the system in the same state as it was initially.
Note that your script should not be a long program. (Mine is less than 20 lines long, not counting documentation.) It is amazing how powerful a short shell script can be.
However, if you have not written a bourne shell script before, then this may be a long project, because you will have a great deal of knowledge to acquire. Getting the bourne shell command-language syntax right is tricky, which may take some trial and error... Don't procrastinate!
As with a normal program, your script is to be carefully documented, and written with attention to readability by someone other than yourself. Make your code hospitable!
Turn in: Use the program script to create a file in which you
Submit your code to
/home/cs/232/current/<yourid>/proj2/, along with the script file, and this grade sheet, which you have altered by putting your name in.
Due date: Monday, Feb. 27, 11:59 p.m. (i.e., one minute before midnight)
CS > 232 > Projects > 2