linux – smbclientを使ってディレクトリを再帰的にダウンロードするには?

download linux samba

get "Path To\Directory\"でディレクトリを取得しようとすると、以下のようなエラーが出ます

NT_STATUS_FILE_IS_A_DIRECTORY opening remote file Path To\Directory

このディレクトリを再帰的にダウンロードするには?

(smbclient v3.6.23を使用。サーバーはWindows 7 Home Editionを実行しているコンピュータです)

  31  hololeap  2014-12-25


ベストアンサー

smbclient manpageあたりでは、mgetコマンドにmaskrecursionpromptを設定します。そして、cdを再帰的に取得したいディレクトリへ

smbclient '\\server\share'
mask ""
recurse ON
prompt OFF
cd 'path\to\remote\dir'
lcd '~/path/to/download/to/'
mget *

あるいは、一行に全部、、、

smbclient '\\server\share' -N -c 'prompt OFF;recurse ON;cd 'path\to\directory\';lcd '~/path/to/download/to/';mget *'`

サーバへの認証が必要な場合は、-Nを落として、connectコマンドのパスワード設定を利用してください

Copy folder with Ubuntu smb client
The smb client for Ubuntu is easy enough to use; however I searched for quite a while before I found the exact syntax for the command to co...

63  Frank Thomas  2014-12-25


tarコマンドをsmbclientにも使えます

smbclient -Tc allfiles.tar /path/to/directory

これにより、smbclientコマンドが実行されたカレントディレクトリにtarアーカイブallfiles.tarが作成されます。その後、tar xf allfiles.tarで再度ファイルを解凍することができます

1  m13r  2020-02-14


Dオプションを使用してディレクトリを設定します

smbclient -D "\" -c ls
smbclient -D "\Path\To\Directory" -c ls

ファイルをダウンロード/取得したい場合は、そうしてください

smbclient -D "\Path\To\Directory" -c "get target /tmp/target"

0  aGuegu  2019-09-12


タイトルとURLをコピーしました