Skip to content

Latest commit

 

History

History
18 lines (14 loc) · 752 Bytes

exercise1.md

File metadata and controls

18 lines (14 loc) · 752 Bytes

Subprocess Exercise 1

  1. Using the subprocess library and Popen, execute the "df -h" command on the local system. The result from this command should be similar to the following:
Filesystem      Size  Used Avail Use% Mounted on
/dev/xvda1       48G   17G   31G  35% /
devtmpfs        987M   60K  987M   1% /dev
tmpfs           997M     0  997M   0% /dev/shm
  1. Using either regular expression processing or Python's split() method, create and print out a data structure that is a list of dictionaries. Your printed data structure should look similar to the following (given the above "df -h" data)
[{'filesystem': '/dev/xvda1', 'usage': '35%'},
 {'filesystem': 'devtmpfs', 'usage': '1%'},
 {'filesystem': 'tmpfs', 'usage': '0%'}]