by
1
7
5,361
7
Top 1% !
Popular
Famous
Pearl of Wisdom
Tagged
Easy-to-find
Specified
Popularity: 1474th place
This snippet is Public
Languagebash
LicenseMIT_X11
OSLinux

smbclient to remotely copy from linux to windows env

This script allows to keep synchronized a windows based client with a linux machine.
Details for smbclient command:
-U: set the credentials to login
-c: execute a command (between quotes)

The command executed includes:
-lcd: set the specified directory to local machine
-mput: copy one or more local files to the remote computer
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/930/smbclient-to-remotely-copy-from-linux-to?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
#!/bin/bash # Linux source directory to copy from: /home/tmp/ # Windows target directory where to copy: \\1.2.3.4\SharedDirectory\filesDir user=myUser pwd=myPwd targetIP=1.2.3.4 sharedDirRoot=SharedDirectory targetDir=filesDir linuxSourceDir=/home/tmp/ echo '- Updating Client folder -' smbclient -U $user%$pwd //$targetIP/$sharedDirRoot -c "cd $targetDir; lcd $linuxSourceDir; prompt off;recurse; mput *;" echo '- Remote Client Updated -'
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus