find free hard disk space remote windows host

Discussion in 'Python' started by Daniel, Aug 31, 2009.

  1. Daniel

    Daniel Guest

    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
    Daniel, Aug 31, 2009
    #1
    1. Advertising

  2. On Mon, 31 Aug 2009 09:11:46 -0700 (PDT), Daniel
    <> 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://wlfraed.home.netcom.com/
    Dennis Lee Bieber, Aug 31, 2009
    #2
    1. Advertising

  3. Daniel

    Tim Golden Guest

    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_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
    Tim Golden, Aug 31, 2009
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jas Shultz
    Replies:
    0
    Views:
    946
    Jas Shultz
    Dec 3, 2003
  2. Marco Schmidt

    Get free disk space under Windows

    Marco Schmidt, Jan 17, 2004, in forum: Java
    Replies:
    13
    Views:
    8,109
  3. Replies:
    1
    Views:
    809
    Sebastian Millies
    Nov 2, 2006
  4. Replies:
    6
    Views:
    1,756
    CBFalconer
    Jun 18, 2007
  5. mohammed_a_o
    Replies:
    0
    Views:
    275
    mohammed_a_o
    Nov 30, 2010
Loading...

Share This Page