smbclient - Send all files in directory

喜夏-厌秋 提交于 2021-02-06 11:10:25

问题


I created a shell script to send files on Linux to Windows via sbmclient.

smbclient //HOST_WINDOWS/D$ -U USER --pass PASSWORD -c "put /tmp/test.txt FOLDER_WINDOWS/test.txt"

That works perfectly.

smbclient //HOST_WINDOWS/D$ -U USER --pass PASSWORD -c "put /tmp/* FOLDER_WINDOWS"

I would like to send all files at once, is it possible?


回答1:


I found that it only works reliably when the local working directory is equal to the directory that you want to upload.

But it's possible to specify a local directory:

smbclient //HOST_WINDOWS/D$ -W domain -U username \
-c 'prompt OFF; recurse ON; cd remote/target/directory; lcd /local/source/directory; mput *'

In interactive mode I guess that would look something like this:

smb: \folder\> recurse ON
smb: \folder\> prompt OFF
smb: \folder\> lcd /local/source/directory
smb: \folder\> cd remote/target/directory
smb: \folder\> mput *



回答2:


Connect with smbclient '//host/folder' -U user --pass Password.

Once connected type the following:

smb: \folder\> recurse
smb: \folder\> prompt
smb: \folder\> mput NameOfDirectoryToBeCopiedToSMBHostFolder*

Note: Don't forget the * at the end of the directory name.



来源:https://stackoverflow.com/questions/38890480/smbclient-send-all-files-in-directory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!