[Linux] Copy data from Linux to Windows with a shell script

Copy data from Linux to Windows with a shell script

Verification environment

-CentOS Linux release 7.6 · Windows Server 2019

  1. Install the samba client on Linux
#Check if the samba client is installed
rpm -q samba-client

#Install samba client
yum install -y samba-client
  1. Create a shared folder on Windows
  2. Access from Linux with smbclient and copy data with put command

#Access Windows shared folders with samba
#「smb: \>Is displayed, access is successful
#Exit samba connection with "exit"
smbclient '\\Windows IP address\Shared folder name' -U domain name\\username%password
smb: \>put Linux data path File name when putting on Windows
smb: \> exit

Example of use

#! /bin/bash
# /var/Under log.For log files
for filePath in `find /var/log/*.log`; do

     # -send put command with c
        smbclient '\\Windows IP address or PC name\Shared folder name' -U username%password-c "put ${filePath}  ${filePath##*/}"  >&1

        #Delete the data on the Linux side if you do not need it
        rm -f $filePath

Recommended Posts

[Linux] Copy data from Linux to Windows with a shell script
Install Windows 10 from a Linux server with PXE
How to run a Python program from within a shell script
[Linux] Write a deployment tool using rsync with a shell script
Execute a script from Jupyter to process
[Ubuntu] How to execute a shell script
Manage logrotate generations with a shell script.
Creating a shell script to write a diary
Data integration from Python app on Linux to Amazon Redshift with ODBC
Verification of how to periodically execute a script on a Linux server on Windows
Data integration from Python app on Windows to Amazon Redshift with ODBC
Copy data from Amazon S3 to Google Cloud Storage with Python (boto)
Easy script migration from CentOS to Oracle Linux
View today's weather forecast with a shell script
Back up from QNAP to Linux with rsync
Extract data from a web page with Python
SSH login to the target server from Windows with a click of a shortcut
A shell script that puts Webmin into Alpine Linux
Copy files directly from Amazon EC2 (Amazon linux) to S3
From buying a computer to running a program with python
I tried collecting data from a website with Scrapy
Python script to create a JSON file from a CSV file
ODBC access to SQL Server from Linux with Python
A real way for people using python 3.8.0-2 from windows to work with multibyte characters
Try to create a battle record table with matplotlib from the data of "Schedule-kun"
A memo that reads data from dashDB with Python & Spark
[Windows] RDP to Windows via Linux
I replaced the Windows PowerShell cookbook with a python script.
A super introduction to Linux
Try programming with a shell!
Access the file with a relative path from the execution script.
Linux script to convert Markdown files from JupyterLab format to Qiita format
Ingenuity to handle data with Pandas in a memory-saving manner
Let's try a shell script
Process the files in the folder in order with a shell script
I'll never forget how to write a shell script, don't forget! !!
I want to install a package from requirements.txt with poetry
[Shell startup] I tried to display the shell on the TV with a cheap Linux board G-cluster
After all, the story of returning from Linux to Windows
I tried changing the python script from 2.7.11 to 3.6.0 on windows10
A python script that converts Oracle Database data to csv
Tokyo Corona: Try to make a simple prediction from open data with the exponential function curve_fit
I will publish a shell script created to reduce the trouble of creating LiveUSB on Linux
[Scp] Copy files locally from Linux server with Tera Term ssh scp
If you want to become a data scientist, start with Kaggle
I want to use a wildcard that I want to shell with Python remove
Conditional branch due to the existence of a shell script file
Create a shell script to run the python file multiple times
I wrote a script to get you started with AtCoder fast!
Try to extract a character string from an image with Python3
Introduction to Data Analysis with Python P17-P26 [ch02 1.usa.gov data from bit.ly]
Data engineers learn DevOps with a view to MLOps. ① Getting started
Get data from MySQL on a VPS with Python 3 and SQLAlchemy
I tried to create Bulls and Cows with a shell program
Write a script to calculate the distance with Elasticsearch 5 system painless
[Spark Data Frame] Change a column from horizontal to vertical (Scala)
Pass a list by reference from Python to C ++ with pybind11
How to determine if a shell script was started in bash
Everything from building a Python environment to running it on Windows
From Elasticsearch installation to data entry
[Infrastructure] Linux command, shell script collection