i trying pull information system drives. issue having being able split information , put needs go. below desired out put if there more 1 volume:
mountpoint: c:\ os volume: true guid: d1dd2893f42711e09090806e6f6e6963 mountpoint: d:\ os volume: false guid: b4584ed2e3b211e2ae7d806e6f6e6963
below information prints out when run have:
mountpoint: c:\ mountpoint: d:\ os volume: true os volume: false guid: d1dd2893f42711e09090806e6f6e6963 guid: b4584ed2e3b211e2ae7d806e6f6e6963
i know doing wrong, not sure how fix it. have looked through interwebs no avail. might naivety.
here code using:
def driveinfo(agent): info = "info " + agent + " | grep " drives = subprocess.popen(info + "'\[mountpoints\]'", shell=true, stdout=subprocess.pipe) drives, err = drives.communicate() strdrives = str(drives) ### volume information mount = subprocess.popen(info + "'\[mountpoints\]'", shell=true, stdout=subprocess.pipe) osvol = subprocess.popen(info + "'\[osvolume\]'", shell=true, stdout=subprocess.pipe) guid = subprocess.popen(info + "'\[guid\]'", shell=true, stdout=subprocess.pipe) ### communicate calls mount, err = mount.communicate() osvol, err = osvol.communicate() guid, err = guid.communicate() ### string conversions mount = str(mount).strip() osvol = str(osvol).strip() guid = str(guid).strip() ### drive information output drive in strdrives: print mount print osvol print guid driveinfo(agent)
your drive variable
iterating on content of strdrives
. however, inside loop, using independant variables (mount, osvol, guid
)
if have more 1 entry in strdrives, expected result duplicated blocks of text => probably, variables don't contain expect (and split not workinjg expected, didn't provide however)
Comments
Post a Comment