first of all, I'm a newbie to Ubuntu OS. I want to execute the Ubuntu terminal command ("sudo lshw -class disk") using python. how can I get the output as a string using the subprocess module in order to write the output into a text file?
In windows, I executed a similar task to this task by:
import subprocess
windows_info = subprocess.check_output(['powershell.exe','get-physicaldisk']).decode('utf-8')
f = open("hardDriveInfo.txt", "w")
f.write("Hard Drive Info" + windows_info)
f.close()