os.listdir("\\\\delta\\public")

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Egor Bolonev

    #1

    os.listdir("\\\\delta\\public")

    import os
    print os.listdir("\\\ \delta\\public" )

    outputs
    ['Bases', 'Docs', 'Drivers', 'Soft', '\xc7\xe0\xec\x e5\xed\xe0
    \xd1\xe5\xf2\xe 5\xe2\xee\xec\x f3 \xce\xea\xf0\xf 3\xe6\xe5\xed\x e8\xfe',
    'Games']


    and
    import os
    print os.listdir("\\\ \delta")

    outputs
    Traceback (most recent call last):
    File "C:\Documen ts and Settings\åÇÏÒ\M y Documents\Scrip ts\test.py", line
    4, in ?
    print os.listdir("\\\ \delta")
    WindowsError: [Errno 53] : '\\\\delta/*.*'

    so how to get list of delta's shares?

  • Michael Hoffman

    #2
    Re: os.listdir(&quo t;\\\\delta\\pu blic")

    Egor Bolonev wrote:
    [color=blue]
    > print os.listdir("\\\ \delta")
    > WindowsError: [Errno 53] : '\\\\delta/*.*'
    >
    > so how to get list of delta's shares?[/color]

    I'm sure someone will post the answer shortly, but you shouldn't expect
    that to work.

    Microsoft Windows XP [Version 5.1.2600]
    (C) Copyright 1985-2001 Microsoft Corp.

    C:\>hostname
    MINIMOO

    C:\>dir \\MINIMOO
    The filename, directory name, or volume label syntax is incorrect.
    --
    Michael Hoffman

    Comment

    • Peter Hansen

      #3
      Re: os.listdir(&quo t;\\\\delta\\pu blic")

      Egor Bolonev wrote:[color=blue]
      > import os
      > print os.listdir("\\\ \delta")
      >
      > outputs
      > Traceback (most recent call last):
      > File "C:\Documen ts and Settings\åÇÏÒ\M y Documents\Scrip ts\test.py",
      > line 4, in ?
      > print os.listdir("\\\ \delta")
      > WindowsError: [Errno 53] : '\\\\delta/*.*'
      >
      > so how to get list of delta's shares?[/color]

      As Michael points out, there's no reason to think that should
      have worked. You can't do a directory of a computer, only
      a drive on the computer, and likewise you can't do a directory
      of a computer on a network, only of the resources is shares.

      Try grabbing the output of os.popen(r"net view \\delta") and
      parse it to get a list of the shares:

      c:\>net view \\monolith
      Shared resources at \\monolith
      Share name Type Used as Comment
      -------------------------------------------------------------------------------
      Printer Print Microsoft Office Document Image Writer
      Printer2 Print hp psc 1310 series
      Printer3 Print HP LaserJet 4
      shared Disk I:
      SharedDocs Disk
      The command completed successfully.

      No doubt you can also do this much more easily with the pywin32
      package, or via COM (using pywin32 or ctypes), but I'll leave
      that response to someone else. Or you could figure it out yourself
      if you are motivated enough.

      -Peter

      Comment

      • Ishwor

        #4
        Re: os.listdir(&quo t;\\\\delta\\pu blic")

        On Sat, 04 Dec 2004 11:40:15 -0500, Peter Hansen <peter@engcorp. com> wrote:
        [color=blue]
        > As Michael points out, there's no reason to think that should
        > have worked. You can't do a directory of a computer, only
        > a drive on the computer, and likewise you can't do a directory
        > of a computer on a network, only of the resources is shares.
        >
        > Try grabbing the output of os.popen(r"net view \\delta") and
        > parse it to get a list of the shares:
        >
        > c:\>net view \\monolith
        > Shared resources at \\monolith
        > Share name Type Used as Comment
        > -------------------------------------------------------------------------------
        > Printer Print Microsoft Office Document Image Writer
        > Printer2 Print hp psc 1310 series
        > Printer3 Print HP LaserJet 4
        > shared Disk I:
        > SharedDocs Disk
        > The command completed successfully.
        >
        > No doubt you can also do this much more easily with the pywin32
        > package, or via COM (using pywin32 or ctypes), but I'll leave
        > that response to someone else. Or you could figure it out yourself
        > if you are motivated enough.
        >
        > -Peter[/color]
        [snip]

        sorry my mistake :)
        --
        cheers,
        Ishwor Gurung

        Comment

        • Egor Bolonev

          #5
          [pywin32] windows shares, was os.listdir(&quo t;\\\\delta\\pu blic&quot;)

          > Try grabbing the output of os.popen(r"net view \\delta") and[color=blue]
          > parse it to get a list of the shares:
          >
          > c:\>net view \\monolith
          > Shared resources at \\monolith
          > Share name Type Used as Comment
          > -------------------------------------------------------------------------------
          > Printer Print Microsoft Office Document Image Writer
          > Printer2 Print hp psc 1310 series
          > Printer3 Print HP LaserJet 4
          > shared Disk I:
          > SharedDocs Disk
          > The command completed successfully.
          >
          > No doubt you can also do this much more easily with the pywin32
          > package, or via COM (using pywin32 or ctypes), but I'll leave
          > that response to someone else. Or you could figure it out yourself
          > if you are motivated enough.[/color]

          how to get list of shares using pywin32?

          Comment

          • Peter Hansen

            #6
            Re: [pywin32] windows shares, was os.listdir(&quo t;\\\\delta\\pu blic&quot;)

            Egor Bolonev wrote:[color=blue][color=green]
            >> Try grabbing the output of os.popen(r"net view \\delta") and
            >> parse it to get a list of the shares:
            >>
            >> c:\>net view \\monolith
            >> No doubt you can also do this much more easily with the pywin32
            >> package, or via COM (using pywin32 or ctypes), but I'll leave
            >> that response to someone else. Or you could figure it out yourself
            >> if you are motivated enough.[/color]
            >
            > how to get list of shares using pywin32?[/color]

            Apparently you weren't motivated enough...

            This is not a Python question. It's a Windows API question.
            Go find the appropriate Windows API and you'll pretty much
            have your answer. There are tools called Google and
            comp.os.windows * and such that would be of great help (in
            conjunction with a little initiative).

            *Then*, and only then, if you can't get it working but have
            tried, is it really appropriate to ask here in the Python
            forum how to do it. Your question at the time would say something
            like "I'm trying to use the WinGetNetworkSh aresA() call to
            retrieve a list of shares but this isn't working... see the
            following traceback for details. Thanks in advance for your help."

            Or you can still just ask here for someone to do the work
            for you. That does often work, strangely enough.

            (It's possible that the problem stems from a language issue.
            If your English is such that you are finding it very difficult
            to understand our responses, or to ask a more detailed question,
            then my apologies for thinking you were rude. It might help
            you to say that this is the problem and then you might get
            more direct help.)

            -Peter

            Comment

            Working...