CS155

PmWiki

edit SideBar

Homework 4: Path Classification

In this assignment, you will write a tcsh script called classify which will classify paths. It will take, as command-line arguments, any number of paths, and will tell you whether each path is:

  • nonexistent
  • a directory
  • a file (as opposed to a directory)
  • readable (by you)
  • writable (by you)
  • executable (by you)
  • empty
  • a tcsh script (the first line starts with “#! /bin/tcsh” or “#!/bin/tcsh”)

Sample Runs

    % ./classify
    usage: ./classify name ...

    % ./classify /tmp
    /tmp: directory readable writable executable

    % ./classify /etc/passwd myemptyfile
    /etc/passwd: file readable
    myemptyfile: file readable writable empty

    % ./classify bogus /bin classify
    bogus: nonexistent
    /bin: directory readable executable
    classify: file readable writable executable tcsh

Requirements

  • Be precise about spelling: the words “nonexistent”, “writable”, and “executable” are tricky.
  • The order of the output is important. For example, “readable” comes before “writable”. Check the sample runs.
  • Emit a usage message if no arguments are given.
  • This must be a pure tcsh script, and not use any other languages such as perl, awk, or bash. You may not use the file command. You may use programs such as expr or grep.
  • The first line of your script must be #! /bin/tcsh -f

How to submit your homework:

    ~cs155/bin/checkin HW4 classify

How to receive negative points:

Turn in someone else’s work.
Edit - History - Print - Recent Changes - Search
Page last modified on December 26, 2008, at 01:25 PM