LoginSignup
2
3

More than 5 years have passed since last update.

smbclientを利用したUNCパスに対するファイルの読み書き

Posted at

概要

Linuxからsmbclientを利用して、Windowsの共有フォルダへの読み書きをする場合
以下のようにして読み書きができます。

イメージ

IO Image

ファイルを読み込む(取得する)

ファイルを取得する際にはFTPコマンドと同様に、作業ディレクトリに取得したファイルが置かれるので、
smbclientコマンドで取得する前に、一度cdで移動してからsmbclientコマンドでファイルを取得する。
また、前提条件としてファイル取得ディレクトリへの書き込み権限がある必要がある。

getの場合
$ cd /var/log/hoge
$ sudo smbclient '\\10.255.1.1\testshare' 'Passw0rd' -U Administrator -D '\SharedDir' -c "prompt;get route.log"

ファイルを書き込む(置く)

ファイルを置く際には、現在の作業ディレクトリにあるファイルをUNCパスに対して置くことができる。

putの場合
$ sudo smbclient '\\10.255.1.1\testshare' 'Passw0rd' -U Administrator -D '\SharedDir' -c "prompt;put app.log"

参考

smbclientを使ってフォルダごとダウンロード
http://t12488mac.blogspot.jp/2011/08/smbclient.html

smbclientコマンド
http://itpro.nikkeibp.co.jp/article/COLUMN/20070618/275055/

2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3