CEG 233: Linux and Windows 

Lab on Scripting: First of Two

   

Table of Contents

  1. Educational Objectives
  2. Background
  3. Lab Experiment
  4. Acknowledgements
  5. References

Educational Objectives

The objectives of this lab experiment are to make you :

  1. Familiar with a few command line utilities
  2. Learn fundamentals of Linux bash scripting
  3. Learn fundamentals of Windows cmd scripting

Background

This is the first of two labs on scripts.  Both labs ask you do something in bash and again in cmd.  It is up to you whether you do the scripts first or second in cmd.  In general, what ever is possible to do in cmd is also possible to do in bash and vice versa, but the relative levels of ease may be different.


Lab Experiment

All work is expected, but not required, to be carried out in the Operating Systems and Internet Security (OSIS) Lab, 429 Russ. But, you are welcome to work wherever. Note that use of both Linux and Windows and other software, that may not always be installed in other facilities, may be needed.

This lab depends on the following topics covered in the following lectures: file name regular expressions, procedures in bash and cmd, bash script file details, and cmd script file details.   Before beginning to work on this lab, you must have read the notes on bash and cmd given in the References.

  1. Linux Bash Pipeline Construction: Construct a pipeline with two pipes and an input redirection and an output append-redirection as in:
      c1 | c2 | c3 < inputInfo.txt >> outputCollection.txt
    The above should be "useful", and you are choosing what the c1, c2, and c3 are and their arguments, if any.   [Hint: Re-read Min list of Linux commands.] Explain what your pipeline construction does in the answers.txt file.
  2. Linux Bash cleanUp.sh Script: This is about keeping a directory free of "junk" files.  To be specific, we want to remove files that are backups and auto-saved versions. 
    1. Develop a bash procedure called cleanUp() that deletes all backup and auto-save files from the given directory . Assume that names of back up files end in either(i) ~ or (ii) .bak, and (iii) auto-save files have names beginning with a #.
    2. Develop a test harness that tests the cleanUp() procedure. The test() procedure should (i) create a new directory named TEST in the current directory,  create a few files (say a dozen each of names chosen by you) that fit the three categories of junk files in TEST, (ii) list-long the TEST directory, (iii) invoke cleanUp TEST, and again (iv) list-long the TEST directory.
  3. In Windows: Develop scripts cleanUp.bat and testScript.bat equivalent to the above in the cmd syntax.  Use standard commands that come with Windows cmd, not the ones in cygwin.
  4. Comment on the levels of ease comparing bash with cmd in each of the above tasks.  Include the commentary in the answers.txt file.
  5. Suppose we wish to compare the performance of cleanUp in bash versus cmd.  Describe how this can be done objectively.  Include this in the answers.txt file.

Turnin

Note the number <n> of this Lab from the course home page and use L<n> as the first argument to turnin.  In addition to the text input files, and the script files you created, turn in myLabJournal.txt, answers.txt, and the usual ReadMe.txt as explained in Expectations.


Acknowledgements


References

  1. Mark G. Sobell, "A Practical Guide to Linux(R) Commands, Editors, and Shell Programming", Prentice Hall, ISBN-10: 0131478230, ISBN-13: 978-0131478237, 2005.
  2. Prabhaker Mateti, Notes on Scripting with BASH, scriptingWithBASH.html.  This article is more specific to our labwork than Sobell's book.  Required Reading.
  3. Prabhaker Mateti, Notes on Scripting with CMD, scriptingWithCMD.html.  This article is more specific to our labwork than the link below.  Required Reading.
  4. For for loop and if statement syntax in cmd, you may wish to web-search in addition to reading the following: http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/for.mspx?mfr=true


Grading Sheet for
CEG 233: Linux and Windows
Lab on Scripting: First of Two

Weight 5%

Instructor:  Prabhaker Mateti 
Grader:

Student LoginID Bonus Points
Item description MaxPts Points
ReadMe.txt,answers.txt, and myLabJournal.txt are submitted with expected content 10 .
bash pipeline construction: works (5 points), useful (10 points), clever (5 points) 20 .
bash cleanUp() Delete all backup and auto-save files. 10 .
bash test harness 10 .
cmd: cleanUp Delete all backup and auto-save files. 10 .
cmd test harness 10 .
ReadMe.txt commentary on comparative ease of scripting 15 .
ReadMe.txt on performance comparison 15 .
Late submission -2% per day late; not accepted after 2 days -- .
Extraneous files submitted: -2 points per file -- .
Files were not submitted using turnin program: -10 points -- .
Total 100 .
 
Copyright © 2009 pmateti@wright.edu Oct 4, 2009