Question: In python Lab 7 Command line arguments and Option Parsing Objectives 1. Demonstrate ability to use command-line arguments 2. Demonstrate ability to use an option

In python

In python Lab 7 Command line arguments and Option Parsing Objectives 1.

Lab 7 Command line arguments and Option Parsing Objectives 1. Demonstrate ability to use command-line arguments 2. Demonstrate ability to use an option parser module to parse options/arguments passed to a script Tasks: Command line arguments allow a command to execute enhanced features and options without directly prompting the user for any additional input. This also allows the command to be ran unattended and/or in a batch mode. In this lab you are required to write a program that simply lists the contents of a directory. The directory contents will either be listed to the console or, if present on the command line, to the log file specified. The directory, the content of which is to be listed, should be the current directory, unless, otherwise specified on the command line. Keep in mind, the directory path specified on the command line needs to be validated that it is in fact an actual directory. If not, display an error message (either to console or to log file) and exit application. If an invalid option was entered in, use exception handling to print out the message and exit application. When listing the contents of the directory to either console or log file, do not list the "" and "." entries. Use the following format: Name You will have your script accept the following command line arguments: Options Short Long Mandatory Description argy ent -h --help Displays "USAGE:

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!