11. You have created a Python script to read a log of users running CRON jobs. The script needs to accept a command line argument for the path to the log file. Which line of code accomplishes this?

  • import sys
  • syslog=sys.argv[1]
  • print(line.strip())
  • usernames = {}

12. Which of the following is a data structure that can be used to count how many times a specific error appears in a log?

  • Continue
  • Search
  • Dictionary
  • Get

13. Which keyword will return control back to the top of a loop when iterating through logs?

  • Continue
  • Get
  • With
  • Search

14. When searching log files using regex, which regex statement will search for the alphanumeric word "IP" followed by one or more digits wrapped in parentheses using a capturing group?

  • r”IP \(\d+\)$”
     
  • r”IP \(\d+\)$”
     
  • r”IP \((\d+)\)$”
     
  • r”IP \((\d+)\)$”

15. Which of the following are true about parsing log files? (Select all that apply.)

  • Load the entire log files into memory.
  • You should parse log files line by line.
  • It is efficient to ignore lines that don’t contain the information we need.
  • We have to open() the log files first.

Leave a Reply