FreeBSD 4.4 + smbclient,smbtar
はじめに
smbclient , smbtar は、samba をインストールした時に一緒にインストールされます。
smbclient は、FreeBSD から Windows の共有ファイルに対して ftp みたいな操作でファイル転送ができます。
また、Windowsプリンタに印刷させることもできます。
smbtar は、FreeBSD から Windows の共有ファイルを tar できます。
今回は、ja-samba-2.0.10.j1.1 内の smbclient , smbtar を使いました。
Windows2000 の共有ディレクトリ
jhon マシンに、c:\hogehoge ディレクトリを作成して、ユーザ名 kenz のみフルコントロールのアクセス権にします。
くれぐれも Everyone フルコントロールにはしないように。
smbclient でファイル転送
jhon の c:\hogehoge を Windows2000ユーザのkenz というユーザで smbclient します。
root でなくても実行できます。
chaco# smbclient \\\\jhon\\hogehoge -U kenz
added interface ip=192.168.0.5 bcast=192.168.0.255 nmask=255.255.255.0
Password:
Domain=[WORKGROUP] OS=[Windows 5.0] Server=[Windows 2000 LAN Manager]
smb: \>
-U kenz というユーザを指定しないと、setenv の LOGNAME か USER が使用されます。
この環境は、LOGNAME=kenz , USER=kenz となっているので、 -U しなくても同じような処理になります。
パスワードは、Windows ユーザのパスワードを入力してください。
help すると、これだけのコマンドがあります。
smb: \> help
ls dir du lcd cd
pwd get mget put mput
rename more mask del open
rm mkdir md rmdir rd
prompt recurse translate lowercase print
printmode queue cancel quit q
exit newer archive tar blocksize
tarmode setmode help ? history
!
smb: \>
リモートディレクトリを確認して、ls する。
smb: \> pwd
Current directory is \\jhon\
smb: \> ls
. D 0 Sun Apr 14 04:17:52 2002
.. D 0 Sun Apr 14 04:17:52 2002
hoge.txt A 19 Sat Apr 13 15:22:10 2002
38154 blocks of size 1048576. 32357 blocks available
ローカルディレクトリを cd
smb: \> lcd /usr/home/kenz
the local directory is now /usr/home/kenz
ファイルを get , put
smb: \> get hoge.txt
getting file \hoge.txt of size 19 as hoge.txt (3.71087 kb/s) (average 3.71094 kb
/s)
smb: \> put hello.c
putting file hello.c as \hello.c (3.02268 kb/s) (average 3.02269 kb/s)
smb: \> ls
. D 0 Sun Apr 14 04:21:17 2002
.. D 0 Sun Apr 14 04:21:17 2002
hello.c A 65 Sun Apr 14 04:21:17 2002
hoge.txt A 19 Sat Apr 13 15:22:10 2002
38154 blocks of size 1048576. 32357 blocks available
終了。
smb: \>
smb: \> quit
smbclient でWindowsプリンタに印刷
Windows2000 にインストールされているプリンタドライバ(PM-760C)に対して印刷させることができます。
Windows2000 のプリンタを共有してください。-U kenz でアクセスしていますが、共有プリンタのセキュリティが Everyone 印刷許可 になっているので、「Windows2000 登録ユーザでログインする」という意味です。
chaco# smbclient \\\\jhon\\pm760c -P -U kenz
added interface ip=192.168.0.5 bcast=192.168.0.255 nmask=255.255.255.0
Password:
Domain=[WORKGROUP] OS=[Windows 5.0] Server=[Windows 2000 LAN Manager]
smb: \> print hogehoge.txt
putting file hogehoge.txt as hogehoge.txt (92.4476 kb/s) (average 92.4479 kb/s)
smb: \> quit
chaco#
smbtar でWindowsファイルを tar する
jhon の c:\hogehoge ディレクトリを、userhoge というユーザでアクセスして、 hoge.tar というファイルで保存する方法です。
> smbtar -s jhon -u userhoge -p ???? -x hogehoge -t hoge.tar -v
server is jhon
share is hogehoge\\
tar args is
tape is hoge.tar
blocksize is
added interface ip=192.168.0.5 bcast=192.168.0.255 nmask=255.255.255.0
Domain=[WORKGROUP] OS=[Windows 5.0] Server=[Windows 2000 LAN Manager]
65 ( 31.7 kb/s) \hello.c
19 ( 18.6 kb/s) \hoge.txt
tar: dumped 2 files and directories
Total bytes written: 1024
> ls -la | grep hoge.tar
-rw-r--r-- 1 kenz kenz 3072 4/14 11:18 hoge.tar
tar の出来上がり。
ちなみに、c:\hogehoge\abc のようなディレクトリを指定する場合は、[-d ディレクトリ名] をオプションで付けます。
次は、Windows 上で tar を展開します。先ほどのコマンドオプションに、-r を付けます。
> smbtar -s jhon -u userhoge -p ???? -x hogehoge -t hoge.tar -v -r
server is jhon
share is hogehoge\\
tar args is
tape is hoge.tar
blocksize is
added interface ip=192.168.0.5 bcast=192.168.0.255 nmask=255.255.255.0
Domain=[WORKGROUP] OS=[Windows 5.0] Server=[Windows 2000 LAN Manager]
restore tar file \hello.c of size 65 bytes
restore tar file \hoge.txt of size 19 bytes
tar: restored 2 files and directories
>
漢字も OK です。
> smbtar -s jhon -u userhoge -p ???? -x hogehoge -t hoge.tar -v
server is jhon
share is hogehoge\\
tar args is
tape is hoge.tar
blocksize is
added interface ip=192.168.0.5 bcast=192.168.0.255 nmask=255.255.255.0
Domain=[WORKGROUP] OS=[Windows 5.0] Server=[Windows 2000 LAN Manager]
0 ( 0.0 kb/s) \新規テキスト文書.txt
tar: dumped 1 files and directories
Total bytes written: 512
> smbtar -s jhon -u userhoge -p ???? -x hogehoge -t hoge.tar -v -r
server is jhon
share is hogehoge\\
tar args is
tape is hoge.tar
blocksize is
added interface ip=192.168.0.5 bcast=192.168.0.255 nmask=255.255.255.0
Domain=[WORKGROUP] OS=[Windows 5.0] Server=[Windows 2000 LAN Manager]
restore tar file \新規テキスト文書.txt of size 0 bytes
tar: restored 1 files and directories
>
戻る
|