We can read the lines and display in Python:
Example Python code:
import os
df = os.popen("df -h /")
#The first line content the label
labels = df.readline()
print(labels)
#we look for the 2nd line only
the2ndLine = df.readline()
print(the2ndLine)
labelsArray = labels.split()[1:6]
print(labelsArray)
dfArray = the2ndLine.split()[1:6]
print(dfArray)
for index in range(len(labelsArray)):
print index, " - ", labelsArray[index], " : ", dfArray[index]
print("-- finished --");
Related:
- Similar in run host command and get result with popen() in C language.
No comments:
Post a Comment