CNIT 34010 UNIX Fundamentals Scripting Project dosutil Description
In this activity you will write a BASH shell script that performs basic UNIX file management functions for DOS/Windows users not familiar with UNIX. The script will take DOS/Windows commands as the first parameter and perform the equivalent UNIX command. Syntax for all commands should match their DOS counterparts as widely documented through various sources.
Preliminaries
Syntax/Style
All variables names should descriptive and represented in ALL CAPS
A comment block at the beginning of the script should list:
o Your name
o The purpose of the script
o Last revision date
o Name and purpose of all variables other than loop indices
Adequate comments should be provided throughout the script to understand its operation
The script should be written as efficiently as possible
o Use good structured programming techniques to minimize repeated code The script must be self-contained
o No support files are required or allowed
o You may use any number of functions within the script itself
Operation
Unless specified in filename parameters, the script will perform all work in the current directory
The first parameter will be the DOS/Windows command the script will emulate
Subsequent parameters will be filenames upon which the script will operate such as:
dosutil copy orig_file dest_file
The script should output the exact UNIX command as executed to stdout Objectives
Phase I due by 11:59 PM, November 17
Your script should accept the following DOS/Windows commands as the first parameter and perform the corresponding UNIX command:
o author output your name in the form last, first
o type output the content of the file in the first parameter
o copycopyafile
o ren rename a file
o movemoveafile
o del delete a file (without asking for confirmation)
o help output a list of supported commands, their action, and required parameters o any invalid parameter output the help message
Output
o Suppress all (standard and error) output from the underlying UNIX commands
Required structure
o All parameters must be copied into descriptive variable names o A case statement is required
o At least two functions must be used
UNIX command execution function
Runs the file manipulation commands and verifies command success
o For this project, all file manipulation commands must be executed within a single function
o The function will be called from your case statement File verification function
Report whether a file exists, is a regular file, or is a directory
o This function should be called prior to running any file
manipulation command
o The result will indicate the syntax required on the file
manipulation command
Build in handling for file/directory overwrites
Give the user an error message and quit if a basic command would overwrite an existing file/directory
Other functions as desired Phase II due by 11:59 PM, December 8
Add robustness to the script
o Make the first script parameter (author, type, etc.) case insensitive
Withonecommandtomassagetheinputratherthanaseriesoforparameters o Verify that all files exist before executing the UNIX command
Output a descriptive error and exit the script gracefully if they do not
o Add new command parameters that automatically overwrite existing files/directories
copy! move! ren!
o Add new command parameters that provide a means to list and change the current directory whereami list current directory
cd change directory
allow changes to subdirectories (sub) or fully qualified paths (/home/myusername/sub)
o Verify the command completed successfully
Output a message to the user for successful or failed commands
Support directories as well as files for command parameters
o Check to see if command targets are files or directories
Modify the command used as required
Add an interactive mode to your script if it is run without parameters
o Use a select loop to prompt the user for a command
type, copy, ren, del, move, help, copy!, move!, ren!,
whereami, cd, sort
o Read the list of files in the current directory into an array using command substitution
Use a select loop to prompt the user for a file/directory
If a directory is selected, change to the directory and re-read the
filenames into your array
Add support for sorting the file list by name, age, or size
o Prompt the user for any additional required parameters
o Perform the action
You do not have to support file and directory names with embedded horizontal spaces
Extension Credit
Add support for file and directory names containing embedded spaces
Ensure that no files scroll off the screen in the select loop in interactive mode
o No more than 23 at a time
Submission
An automated script will evaluate basic script functionality. Submit your script via the submit command on the script server. The syntax for submit is as follows:
submit phase# file_to_submit
To submit a file named dosutil to phase 1 you would enter: submit phase1 dosutil
In addition to submitting your script via submit, you should also submit your script via Blackboard for grade assignment. You can FTP or SCP (preferred) your script from the script server to your computer for submission.
Be sure to submit the correct script to the correct phase assignment
Reviews
There are no reviews yet.