Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > find free hard disk space remote windows host

Reply
Thread Tools

find free hard disk space remote windows host

 
 
Daniel
Guest
Posts: n/a
 
      08-31-2009
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:

>>> mystat = os.stat('//remotehost/share/')
>>> mystat

(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
 
Reply With Quote
 
 
 
 
Dennis Lee Bieber
Guest
Posts: n/a
 
      08-31-2009
On Mon, 31 Aug 2009 09:11:46 -0700 (PDT), Daniel
<(E-Mail Removed)> declaimed the following in
gmane.comp.python.general:
>
> 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()
--
Wulfraed Dennis Lee Bieber KD6MOG
http://www.velocityreviews.com/forums/(E-Mail Removed) HTTP://wlfraed.home.netcom.com/

 
Reply With Quote
 
 
 
 
Tim Golden
Guest
Posts: n/a
 
      08-31-2009
Daniel wrote:
> 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:
>
>>>> mystat = os.stat('//remotehost/share/')
>>>> mystat

> (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_co...ercentage_free

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

TJG
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hard drive is Disk 0 CHANGES to hard drive is Disk 1??? And still works!!! Spin Computer Support 7 04-09-2008 09:04 PM
How to find the total and free memory available in RAM. and used & free space available in each disk? kathirvel.com@gmail.com Java 1 11-02-2006 02:31 PM
Remote Assistance fails to connect, remote remote host name could not be resolved Peter Sale Wireless Networking 1 12-11-2004 09:09 PM
copy my first hard disk info onto my second hard disk gary Computer Support 2 10-28-2004 10:49 PM
Getting "not enough disk space error" when there is plenty of disk space Jas Shultz ASP .Net 0 12-03-2003 05:07 PM



Advertisments