find free hard disk space remote windows host

D

Daniel

Hello,

I'm trying to determine the amount of free hard disk space on a remote
windows host. Seems like this should be simple, but it's giving me
grief. Here's what I've tried:
(16895, 0L, 0, 0, 0, 0, 0L, 1251731920, 1251731289, 1249399952)

For some reason it doesn't show the details about space on the remote
path.

Next I tried this:

subprocess.call('dir //remotehost/share/ | find "bytes free"',
shell=True)

But this only returns the status, not the output, which is what I
need.

How can I determine the amount of free hard drive space on a remote
windows host using python?

Thanks
 
D

Dennis Lee Bieber

subprocess.call('dir //remotehost/share/ | find "bytes free"',
shell=True)

But this only returns the status, not the output, which is what I
need.
As I'd expect... you'd need to read the stdout from the process...
How can I determine the amount of free hard drive space on a remote
windows host using python?
Uhm... maybe...

win32file.GetFreeDiskSpace()
 
T

Tim Golden

Daniel said:
Hello,

I'm trying to determine the amount of free hard disk space on a remote
windows host. Seems like this should be simple, but it's giving me
grief. Here's what I've tried:

(16895, 0L, 0, 0, 0, 0, 0L, 1251731920, 1251731289, 1249399952)

Assuming you have the necessary security levels,
WMI's quite good at this kind of thing. See this
example:

http://timgolden.me.uk/python/wmi_cookbook.html#percentage_free

and just add "remotehost" as the first parameter to the
wmi.WMI () call. (And I recommend find_classes=False) for
speed.

TJG
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top