Project 6
This project tests your ability to
- work with command line arguments;
- work with text stream I/O methods;
- use different methods of Array object.
Please write a script named tail.js that:
- takes a file name as an argument from the command line (this is a required argument);
- another argument (optional) is to be an integer number;
- reads the specified file;
- prints a number of the last lines from the file;
- the number of lines to print is either 10 (the default value) or the number assigned by the other
argument.
Additional requirements are:
- before opening the file the script should check if the file with the given name exists and readable
(for this check the attributes of the file);
- use method WScript.Echo() to print all the lines.
- use try...catch to avoid default error messages and try
to from possible errors.