omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Python SMB Connection

    Pythonista
    3
    85
    24339
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • cvp
      cvp @DavinE last edited by

      @DavinE strange, I use this successfully

      			ip = bios.queryName(self.smb_name)
      			return ip[0]
      
      DavinE 1 Reply Last reply Reply Quote 0
      • DavinE
        DavinE @cvp last edited by

        @cvp said:

        @DavinE strange, I use this successfully

        			ip = bios.queryName(self.smb_name)
        			return ip[0]
        

        in your case whats the self.smb_name? Server Name ?

        cvp 2 Replies Last reply Reply Quote 0
        • cvp
          cvp @DavinE last edited by

          @DavinE sorry, a mistake more,

          			bios = NetBIOS()
          			srv_name = bios.queryIPForName(remote_smb_ip, timeout=timeout)
          			return srv_name[0]
          
          1 Reply Last reply Reply Quote 0
          • DavinE
            DavinE last edited by

            @cvp
            hmm...
            I get the same output as i get with my code ELEKTROTECHNIK

            cvp 1 Reply Last reply Reply Quote 0
            • cvp
              cvp @DavinE last edited by

              @DavinE said:

              in your case whats the self.smb_name? Server Name

              Yes

              DavinE 1 Reply Last reply Reply Quote 0
              • cvp
                cvp @DavinE last edited by

                @DavinE said:

                local_machine_name = socket.gethostname()
                server_machine_name = netbios.queryIPForName(server_IP)

                Did you try with

                local_machine_name  = socket.gethostname()[0]
                server_machine_name = netbios.queryIPForName(server_IP)[0]
                
                DavinE 1 Reply Last reply Reply Quote 0
                • DavinE
                  DavinE @cvp last edited by

                  @cvp said:

                  @DavinE said:

                  in your case whats the self.smb_name? Server Name

                  Yes

                  When i use your code above

                  ip = bios.queryName(self.smb_name)
                              return ip[0]
                  

                  server_machine_name = netbios.queryIPForName(server_IP)[0]

                  print(server_machine_name) ELEKTROTECHNIK
                  print(local_machine_name) Davin
                  print(netbios.queryName(server_machine_name)) and here None

                  why none ?

                  1 Reply Last reply Reply Quote 0
                  • DavinE
                    DavinE @cvp last edited by DavinE

                    @cvp said:

                    @DavinE said:

                    local_machine_name = socket.gethostname()
                    server_machine_name = netbios.queryIPForName(server_IP)

                    Did you try with

                    local_machine_name  = socket.gethostname()[0]
                    server_machine_name = netbios.queryIPForName(server_IP)[0]
                    

                    This did not work here i get only the first letter

                    local_machine_name = socket.gethostname()[0]

                    in my case D

                    cvp 1 Reply Last reply Reply Quote 0
                    • cvp
                      cvp @DavinE last edited by

                      @DavinE could you try with my module
                      SMB_client.py

                      and

                      from SMB_client import SMB_client
                      
                      my_smb = SMB_client(username='admin',password='admin',smb_name='share')
                      my_smb.connect()
                      
                      tree = my_smb.getRemoteTree()
                      for elem in tree:
                      	print(elem)
                      
                      DavinE 1 Reply Last reply Reply Quote 0
                      • DavinE
                        DavinE @cvp last edited by

                        @cvp said:

                        @DavinE could you try with my module
                        SMB_client.py

                        and

                        from SMB_client import SMB_client
                        
                        my_smb = SMB_client(username='admin',password='admin',smb_name='share')
                        my_smb.connect()
                        
                        tree = my_smb.getRemoteTree()
                        for elem in tree:
                        	print(elem)
                        

                        yeah i tried it but i can retry it...

                        i do not have SMB_client installed
                        should i install it ? and try

                        cvp 2 Replies Last reply Reply Quote 0
                        • cvp
                          cvp @DavinE last edited by

                          @DavinE did you see the link in my post?

                          DavinE 1 Reply Last reply Reply Quote 0
                          • cvp
                            cvp @DavinE last edited by

                            @DavinE said:

                            should i install it ? and try

                            Sure

                            1 Reply Last reply Reply Quote 0
                            • DavinE
                              DavinE @cvp last edited by

                              @cvp said:

                              @DavinE did you see the link in my post?

                              yeah sry, that's my mistake....

                              i get this output:

                              Error on line 47 TypeError 'NoneType' object is not subscriptable
                              Error on line 62 TypeError str, bytes or bytearray expected, not NoneType
                              Error on line 87 NotReadyError SMB connection not authenticated
                              
                              cvp 2 Replies Last reply Reply Quote 0
                              • cvp
                                cvp @DavinE last edited by

                                @DavinE strange, I'll check, my smb connection works

                                DavinE 1 Reply Last reply Reply Quote 0
                                • DavinE
                                  DavinE @cvp last edited by

                                  @cvp said:

                                  @DavinE strange, I'll check, my smb connection works

                                  Thanks for your Work @cvp

                                  1 Reply Last reply Reply Quote 0
                                  • cvp
                                    cvp @DavinE last edited by cvp

                                    @DavinE could you try, with your own user, pwd, server

                                    from SMB_client import SMB_client
                                    import keychain
                                    
                                    server_ftp = 'VOO-USB'
                                    user = 'voo'
                                    # get password from keychain
                                    pwd = keychain.get_password(server_ftp,user)
                                    my_smb = SMB_client(username=user,password=pwd, smb_name='VOO-USB', print_errors=False)
                                    my_smb.connect()
                                    print(my_smb.getRemoteDir('', '*'))
                                    
                                    DavinE 1 Reply Last reply Reply Quote 0
                                    • cvp
                                      cvp last edited by

                                      smb_files = my_smb.getRemoteDir('', '*')
                                      for smb_file in smb_files:
                                      	smb_filename = smb_file.filename
                                      	print(smb_file.filename)
                                      
                                      1 Reply Last reply Reply Quote 0
                                      • DavinE
                                        DavinE @cvp last edited by

                                        @cvp said:

                                        @DavinE could you try, with your own user, pwd, server

                                        from SMB_client import SMB_client
                                        import keychain
                                        
                                        server_ftp = 'VOO-USB'
                                        user = 'voo'
                                        # get password from keychain
                                        pwd = keychain.get_password(server_ftp,user)
                                        my_smb = SMB_client(username=user,password=pwd, smb_name='VOO-USB', print_errors=False)
                                        my_smb.connect()
                                        print(my_smb.getRemoteDir('', '*'))
                                        

                                        i get None

                                        but is it correct that i set my pass in server_ftp

                                        cvp 3 Replies Last reply Reply Quote 0
                                        • cvp
                                          cvp @DavinE last edited by

                                          @DavinE said:

                                          but is it correct that i set my pass in server_ftp

                                          Forget my keychain process. In all my scripts, I store my passwords in keychain.
                                          Use your username='xxx',password='xxx',smb_name='xxx'

                                          1 Reply Last reply Reply Quote 0
                                          • cvp
                                            cvp @DavinE last edited by cvp

                                            @DavinE and put your ip as server (my server has an ip but also a name)

                                            1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post
                                            Powered by NodeBB Forums | Contributors