A More Complete Application

After a long hiatus, we are going to resume work on our sys_info_page program. Our next addition will add several command-line options to the program as follows:

  • Output file. We will add an option to specify a name for a file to contain the program’s output. It will be specified as either -f file or --file file.

  • Interactive mode. This option will prompt the user for an output filename and will determine if the specified file already exists. If it does, the user will be prompted before the existing file is overwritten. This option will be specified by either -i or --interactive.

  • Help. Either -h or --help may be specified to cause the program to output an informative usage message.

Here is the code needed to implement the ...

Get The Linux Command Line now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.