smbclient— ftp-like client to access SMB/CIFS resources
on servers
smbclient
is 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.
Synopsis
smbclientservicename[
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.
-NIf 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=filename
This 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 = <value>
password = <value>
domain = <value>
-U|--user=username[%password]
Sets the SMB username or username and password.
-T tar options备份服务器端分享的全部文件,并打包成tar格式的文件。
smbclient may be used to create
tar(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.
-N
is 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 <directory name>chmod file mode in octal
chown file uid gid
close <fileid>
lcd [directory name]改本地所在的路径
logon <username> <password>
ls <mask>See the dir command above.
mkdir/md <directory name> 在server上创建文件夹
put <local file name> [remote file name] 上传单个文件
mask <mask>rm <mask> Remove all files matching
mask
from the current
working directory on the server.
- rmdir <directory name>
Remove the specified directory (user access
privileges permitting) from the server.
- mget <mask>
Copy all files matchingmask
from the server to
the machine running the client.
- mput <mask> 上传多个文件
Copy all files matchingmask
in 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.
- recurse
Toggle 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<IP地址>][-d<排错层级>][-i<范围>][-I<IP地址>]
[-l<记录文件>][-M<NetBIOS名称>][-n<NetBIOS名称>][-O<连接槽选
项>][-p<TCP连接端口>][-R<名称解析顺序>][-s<目录>][-t<服务器字
码>][-T<tar选项>][-U<用户名称>][-W<工作群组>]
补充说明:SMB与CIFS为服务器通信协议,常用于Windows95/98/NT等系统。smbclient可让Linux系统存取Windows系统所分享的资源。
参 数:
[网络资源] [网络资源]的格式为//服务器名称/资源分享名称。
[密码] 输入存取网络资源所需的密码。
-B<IP地址> 传送广播数据包时所用的IP地址。
-d<排错层级> 指定记录文件所记载事件的详细程度。
-E 将信息送到标准错误输出设备。
-h 显示帮助。
-i<范围> 设置NetBIOS名称范围。
-I<IP地址> 指定服务器的IP地址。
-l<记录文件> 指定记录文件的名称。
-L 显示服务器端所分享出来的所有资源。
-M<NetBIOS名称> 可利用WinPopup协议,将信息送给选项中所指定的主机。
-n<NetBIOS名称> 指定用户端所要使用的NetBIOS名称。
-N 不用询问密码。
-O<连接槽选项> 设置用户端TCP连接槽的选项。
-p<TCP连接端口> 指定服务器端TCP连接端口编号。
-R<名称解析顺序> 设置NetBIOS名称解析的顺序。
-s<目录> 指定smb.conf所在的目录。
-t<服务器字码> 设置用何种字符码来解析服务器端的文件名称。
-T<tar选项> 备份服务器端分享的全部文件,并打包成tar格式的文件。
-U<用户名称> 指定用户名称。
-W<工作群组> 指定工作群组名称。