[Samba] Controlling smbclient from python weirdness

Nicholas Piper nick-samba at nickpiper.co.uk
Wed Nov 20 17:39:01 GMT 2002


I've written a python wrapper around the smbclient program, so that I
can list/upload/download from Windows shares.

Using smbclient 2.0.9 or Version 2.2.5-2 for Debian, my wrapper works
well and is able to control the smbclient process via pipes well. With
both smbclient 2.999+3.0cvs20020723-1 and 2.999+3.0.alpha20-3 (on a
Debian box) the smbclient responses appear to be not always BEFORE the
new smbclient command prompt. I expect this kind of behaviour:

smb: \> ls
  Ranger                              D        0  Tue Nov 20 12:45:40 2001
  telix                               D        0  Tue Nov 20 14:56:28 2001
  DOS                                 D        0  Tue Nov 20 14:57:32 2001

                65526 blocks of size 32768. 65526 blocks available
smb: \>

But with the more recent smbclient versions I get this:

smb: \> ls 
smb: \> 
  Ranger                              D        0  Tue Nov 20 12:45:40 2001 
  telix                               D        0  Tue Nov 20 14:56:28 2001 
  DOS                                 D        0  Tue Nov 20 14:57:32 2001 
 
                65526 blocks of size 32768. 65526 blocks available 

And once I saw this:

smb: \> ls 
  Ranger                              D        0  Tue Nov 20 12:45:40 2001 
  telix                               D        0  Tue Nov 20 14:56:28 2001 smb: \> 
  DOS                                 D        0  Tue Nov 20 14:57:32 2001 
 
                65526 blocks of size 32768. 65526 blocks available 

As I look for the command prompt to know smbclient has finished giving
me the reply, this messes things up.

I control smbclient via popen4() in python2.1. I've found this strange
placement in the prompt to be the reason my code isn't working, via
running smbclient like this:

c = popen2.Popen4("smbclient //machine/c -N | tee /tmp/smb_out.txt)

And watching smb_out.txt (Popen3() acts the same way).

Is this likely to be an issue with how python talks to the process ? I
have not included a test case in this mail because it would make it
longer than it already is, but can provide one.

Note that when I talk to the smbclient myself (via starting one from a
shell) it appears to act normally.

Is there anymore information I could provide to help find out why this
occurs ?

Thanks,

 Nick

-- 
Part 3 MEng Cybernetics; Reading, UK       http://www.nickpiper.co.uk/
GPG Encrypted mail welcome!                             1024D/3ED8B27F
Choose life. Be Vegan :-) Please reduce needless cruelty + suffering !



More information about the samba mailing list