File Processing

Pacman Warnings

Print out all log lines in the pacman-install.log file that contain “warning”.

The first 4 line of output should look like this:

[2010-05-28 16:04] warning: /etc/sensors3.conf saved as /etc/sensors3.conf.pacorig
[2010-05-28 16:06] warning: /etc/mime.types saved as /etc/mime.types.pacorig
[2010-05-28 16:07] warning: /etc/mysql/my.cnf saved as /etc/mysql/my.cnf.pacorig
[2010-05-28 16:07] WARNING: The host 'Lab1' could not be looked up with resolveip.

SSH Users

Using the gzipped file sshd.log.gz, write a program, ssh_users.py, that prints all users that logged in successfully.

To find the user login, start by searching for the phrase “session opened for user “.

The output should look like this:

trey
diane
melanie

Hint

You can use the open function in the gzip module to read this gzipped file.

SSH Login Days

Using the same gzipped file, sshd.log.gz, create a program, ssh_login_days.py, that prints each day that each user successfully logged in, in chronological order.

The output should look like this:

Jun 04 trey
Jun 04 diane
Jun 05 diane
Jun 05 trey
Jun 05 melanie
Jun 07 melanie
Jun 07 trey

Tree Parser

Create a program that will accept a file like this:

a
    b
    c
        d
    e
        f
g
    h
        i
        j
k
    l
        m

And will output the leaf nodes from this program like this:

/ a / b
/ a / c / d
/ a / e / f
/ g / h / i
/ g / h / j
/ k / l / m

Hint

You may want to use your DoublyLinkedNode class from your classes.py file.