pysmb icon indicating copy to clipboard operation
pysmb copied to clipboard

storeFile writing 0 byte files

Open siznad opened this issue 10 years ago • 12 comments

I'm using pysmb 1.1.13 with Python 2. I'm using the storeFIle function to copy files to a share. It is writing 0 byte files. The same piece of code works just fine on a different share on a different server.

Here's the code.

from smb.SMBConnection import SMBConnection from smb import smb_structs smb_structs.SUPPORT_SMB2 = False

client_machine_name = 'TESTPC' server_name = 'testsvr' server_ip = 'testsvr' username = 'bob' password = 'password' inputfile = 'text.txt'

conn = SMBConnection(username, password, client_machine_name, server_name, use_ntlm_v2 = True)

conn.connect(server_ip, 139)

with open(inputfile, 'r') as file_obj: numBytes = conn.storeFile('workgroup', 'testpath', file_obj, timeout=600)

conn.close()

Not sure what is different about each share that one would result in 0 byte files. Any ideas on how to troubleshoot this?

siznad avatar Oct 25 '14 17:10 siznad

@siznad : Can you provide more information about the remote server? What are the versions of the OS/Samba service that is working and is not working?

If you can, please provide the TCP packet capture of both working and non-working scenarios.

Thank you

miketeo avatar Oct 25 '14 18:10 miketeo

Hi Michael,

Thanks for the quick response. I don't have the details yet about the remote servers. I can get that next week. But I did already take network captures for both scenarios.

Attached are the working and non-working captures.

For the not working scenario use filter 'tcp.stream eq 0'

For working, use filter 'tcp.stream eq 110'

Thanks.

On 2014-10-25 13:44, Michael Teo wrote:

@siznad [1] : Can you provide more information about the remote server? What are the versions of the OS/Samba service that is working and is not working?

If you can, please provide the TCP packet capture of both working and non-working scenarios.

Thank you

Reply to this email directly or view it on GitHub [2].

Links:

[1] https://github.com/siznad [2] https://github.com/miketeo/pysmb/issues/23#issuecomment-60492929

siznad avatar Oct 25 '14 19:10 siznad

@siznad : I think the attachments are not available on github when you reply via email. Can you email me your packet captures directly at [email protected] ? Thanks

miketeo avatar Oct 26 '14 06:10 miketeo

Hi, I sent you the captures to [email protected]. Just wanted to confirm you got them. John

siznad avatar Oct 27 '14 13:10 siznad

Thank goodness you have probed me on this. Your packet capture has ended up in my spam box. I will look into this.

miketeo avatar Oct 27 '14 15:10 miketeo

@siznad : I was looking through your packet captures. The remote CIFS/SMB server for the non-working looks interesting; it seems to be a NAS. Can you provide more details on the remote server? Thank you.

miketeo avatar Oct 28 '14 05:10 miketeo

It is NAS. It's a SAN storage running NetApp.

siznad avatar Oct 28 '14 21:10 siznad

Hi Mike,

Any idea what the issue could be?

John

siznad avatar Nov 13 '14 20:11 siznad

@siznad: Unfortunately, I do not have access to a NetApp storage facility to troubleshoot. I'm tied down with my work for this month, and will look into this once my time loosen up.

miketeo avatar Nov 19 '14 04:11 miketeo

@miketeo @siznad Don't know if this is already solved, but using is_direct_tcp=True on the SMBConnection solved the problem for me. Also, you might wanna use port 445 instead of 139.

joselitosn avatar Jun 24 '15 18:06 joselitosn

I had the same symptom and in my case it was because the opened file was positioned to the end of the file. The storeFile method just performs read() to get the data, so it wasn't finding anything at the end of the file. I did a file_obj.seek(0) before writing and this fixed it.

G-Goldstein avatar Nov 26 '15 16:11 G-Goldstein

@G-Goldstein 6 years later, thank you so much for this! Saved me.

zrachlin avatar May 13 '21 15:05 zrachlin