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 copy whole directories instead of just files. I have done this a couple of times now but have never documented it so I figured I should for future reference.
I also feel that the previous times I might have done it a different way so I wouldn't be surprised if some of you can suggest yet another way to accomplish this.
What I used was this (at the Ubuntu terminal).
(My Users folder under my C:\ drive was shared from my Windows machine)
You can either use the statements separately in the order provided above or you could use it in one statement as in the following example:
The above line will get the "New Movie" folder from the machine specified by the IP address.
The -N parameter: this parameter suppresses the normal password prompt from the client to the user
The -c parameter: this parameter specifies that a command to be executed will follow. It is very useful in scripts
Finally I have it documented :)
Let me know if I can be of more assistance!
Thanks,
Hermann
I also feel that the previous times I might have done it a different way so I wouldn't be surprised if some of you can suggest yet another way to accomplish this.
What I used was this (at the Ubuntu terminal).
(My Users folder under my C:\ drive was shared from my Windows machine)
smbclient //192.168.1.2/Users
cd <the directory path of the parent folder of the directory that you want to copy)
recurse (this is so that smb recursively copies all subdirectories and files)
mget <the folder that you want to copy>
You can either use the statements separately in the order provided above or you could use it in one statement as in the following example:
smbclient //192.168.1.2/Users -N -c 'prompt;recurse;cd Hermann\Downloads\;mget "New Movie"'
The above line will get the "New Movie" folder from the machine specified by the IP address.
The -N parameter: this parameter suppresses the normal password prompt from the client to the user
The -c parameter: this parameter specifies that a command to be executed will follow. It is very useful in scripts
Finally I have it documented :)
Let me know if I can be of more assistance!
Thanks,
Hermann
You're my hero.
ReplyDeleteand my ;)
ReplyDeleteThanks for sharing!
ReplyDeleteI used your command line and made one for sending files aswell:
To send files to windows
$ smbclient -U Administrator //193.168.0.2/c$ -c 'cd "Program Files"; put myfile.txt'
To download a folder from windows to ubuntu:
$ smbclient -U Administrator //193.168.0.2/c$ -c 'prompt;recurse;cd "Program Files/";mget "MyFolder"'
Thanks, Jeppe. Very useful. Thanks for taking the time to share it.
DeleteHi, my name is Kin.LHP, I'm brazilian!
ReplyDeleteObrigado, me ajudou muito.
Eu também consegui da seguinte forma:
CONNECT
:~$ smbclient //HOSTNAME/SHARED_FOLDER/ --user=USER
SEND FILE
smb: \> put FILE
SEND FOLDER
smb: \> tarmode
smb: \> recurse
smb: \> prompt
smb: \> mput FOLDER (without \ )
GET FILE
smb: \> get FILE
GET FOLDER
smb: \> tarmode
smb: \> recurse
smb: \> prompt
smb: \> mget FOLDER\ (with \ )
Thank you very much for sharing. You're right! This works as well. Gostei muito de ler o seu portugues! Gosto muito de falar portugues mas faz muito tempo que nao falo frequentemente. Obrigado por sua solucao. (Nao tenho o teclado com todas as sinais de gramatica).
Deleteafter get command i got Error opening local file staff.txt what can i do?
DeleteI am constantly surprised by the amount of information accessible on this subject. What you presented was well researched and well written to get your stand on this over to all your readers. Thanks a lot my dear. BinaryToday.com
ReplyDelete