smbclient
— ftp-like client to access SMB/CIFS resources
on servers
smbclientis a client that can
'talk' to an SMB/CIFS server. It offers an interface
similar to that of the ftp program.
Operations include things like getting files from the server
to the local machine, putting files from the local machine to
the server, retrieving directory information from the server
and so on.
Synopsissmbclientservicename[password] [-A] [-E] [-Lhost] [-Mhost] [-IIPnumber
] [-N] [-P] [-Uusername] [-ddebuglevel] [-llogbasename ] [-nnetbiosname ] [-Wworkgroup] [-Osocketoptions ] [-pportnumber ] [-ccommandstring ] [-Ttaroptions ] [-Dinitialdirectory ]
-L列出可用的共享文件夹
This option allows you to look at what services are available
on a server.
-N
If specified, this parameter suppresses the normal password
prompt from the client to the user. This is useful when accessing a service
that does not require a password.
-A|--authentication-file=filenameThis option allows
you to specify a file from which to read the username and
password used in the connection. The format of the file is
username =
password =
domain =
-U|--user=username[%password]
Sets the SMB username or username and password.-T tar options备份服务器端分享的全部文件,并打包成tar格式的文件。
smbclient may be used to createtar(1)compatible backups of all the files on an SMB/CIFS
share.
-D initial directory改变登录到windows上的目录
Change to initial directory before starting. Probably
only of any use with the tar -T option.
-c command string一般用于脚本,添加smbclient命令和打印信息,每个smbclient命令用;隔开
command string is a semicolon-separated list of
commands to be executed instead of prompting from stdin.-Nis implied by-c.
This is particularly useful in scripts and for printing stdin
to the server, e.g.-c 'print -'.Smbclient 命令
?[command] --help
! [shell command]
cd
chmod file mode in octalchown file uid gidclose lcd [directory name]改本地所在的路径
logon ls See the dir command above.
mkdir/md 在server上创建文件夹put [remote file name] 上传单个文件
mask
rm
Remove all files matchingmaskfrom the current
working directory on the server.
rmdir Remove the specified directory (user access
privileges permitting) from the server.mget Copy all files matchingmaskfrom the server to
the machine running the client.mput 上传多个文件Copy all files matchingmaskin the current working
directory on the local machine to the current working directory on
the server.prompt 关闭/打开 提示Toggle prompting for filenames during operation
of the mget and mput commands.recurseToggle directory recursion for the commands mget
and mput.-------------------------------------------关于如何上传/下载多个符合条件的文件可使用recurse, mask, mput, prompt。具体用法的用例参照http://lists.samba.org/archive/samba-technical/2000-January/006558.html---------------------------------------------有个烦了我很久的问题,貌似smbclient命令无法直接上传文件夹,我又不想要这个文件夹打包上传。所以我只好在windows共享上创建一个文件夹,再把linux本地中该文件夹内的所有文件上传上去。
如 要把linux 本地的mydir文件夹上传到windows共享的 user/document 文件夹内
cd mydir
smbclient //193.168.1.105/user -D "\document" -c "mkdir mydir; cd mydir; prompt; mput *" -N -U 'username%password'
有点繁琐,不知道有没有其他更好的方法把linux上的文件夹上传到windows共享server中???
Reference:
-------------------------
http://www.tamos.net/guide/manpages/samba/smbclient.1.html
http://www.samba.org/samba/docs/man/manpages-3/smbclient.1.html
http://www.computerhope.com/unix/smbclien.htm
http://learnlinux.tsf.org.za/courses/build/net-admin/ch08s02.html
http://lists.samba.org/archive/samba-technical/2000-January/006558.html
------------------------------smbclient(samba client)
功能说明:可存取SMB/CIFS服务器的用户端程序。
语 法:smbclient [网络资源][密
码][-EhLN][-B][-d][-i][-I]
[-l][-M][-n][-O
项>][-p][-R][-s][-t
码>][-T][-U][-W]
补充说明:SMB与CIFS为服务器通信协议,常用于Windows95/98/NT等系统。smbclient可让Linux系统存取Windows系统所分享的资源。
参 数:
[网络资源] [网络资源]的格式为//服务器名称/资源分享名称。
[密码] 输入存取网络资源所需的密码。
-B 传送广播数据包时所用的IP地址。
-d 指定记录文件所记载事件的详细程度。
-E 将信息送到标准错误输出设备。
-h 显示帮助。
-i 设置NetBIOS名称范围。
-I 指定服务器的IP地址。
-l 指定记录文件的名称。
-L 显示服务器端所分享出来的所有资源。
-M 可利用WinPopup协议,将信息送给选项中所指定的主机。
-n 指定用户端所要使用的NetBIOS名称。
-N 不用询问密码。
-O 设置用户端TCP连接槽的选项。
-p 指定服务器端TCP连接端口编号。
-R 设置NetBIOS名称解析的顺序。
-s 指定smb.conf所在的目录。
-t 设置用何种字符码来解析服务器端的文件名称。
-T 备份服务器端分享的全部文件,并打包成tar格式的文件。
-U 指定用户名称。
-W 指定工作群组名称。