I am going to share my program that I made whenever I had time.
I made it using SCP command.
SCP uses Secure Shell (SSH) to transfer file between client and remote server, It's fast and secure.
In this article, I will show you two examples.
1. First example - copying file from several remote server
If you need to transfer file to several remote server, You can use it below program.
The program requires file that has many linux ip or username information like below.
nklee@172.19.136.18
nklee@172.19.136.18
nklee@172.19.136.18
#!/bin/sh
if [ $# -lt 3 ]
then
echo "Usage : $0 {로컬파일or디렉토리} {원격경로} {서버파일리스트}"
exit 1
fi
servers=`cat $3`
for server in $servers
do
echo "-------------------------------------------------"
echo "scp -r $1 ${server}:$2"
echo "-------------------------------------------------"
scp -r $1 ${server}:$2
echo "\n"
done
You can use following UNIX command.
1 | $ ./scp_download.sh /home/nklee/index.html . servers | cs |
2. Second example - copying file to several remote server
If you need to transfer file from several remote servers, You can use it below program.
#!/bin/sh
if [ $# -lt 3 ]
then
echo "Usage : $0 {로컬파일or디렉토리} {원격경로} {서버파일리스트}"
exit 1
fi
servers=`cat $3`
for server in $servers
do
echo "-------------------------------------------------"
echo "scp -r $1 ${server}:$2"
echo "-------------------------------------------------"
scp -r $1 ${server}:$2
echo "\n"
done
You can use following UNIX command.
1 | $ ./scp_upload.sh ./index.html /home/nklee/test servers | cs |
Thanks for reading this article so far.
If you have any questions or feedback then please write your comment.
'프로그래밍' 카테고리의 다른 글
RestTemplate 사용시 URL 인코딩 이슈 (0) | 2019.10.04 |
---|---|
[Spring] redirect: 접두사는 항상 http로 리다이렉트 된다. (0) | 2019.09.20 |
[spring boot 2.1] 애노테이션 정리 (0) | 2019.08.05 |
티스토리 API 연동 (1) | 2018.09.18 |
3. Spring Cloud를 이용한 MSA 구축하기 - config client (0) | 2018.05.15 |
linux 장비 원격 실행 프로그램 (0) | 2018.05.08 |
spring boot swagger2 사용하기 (0) | 2018.02.01 |
16. [JPA] Bulk Insert (0) | 2017.12.14 |