Skip to content

Instantly share code, notes, and snippets.

@kurozumi

kurozumi/download.sh

Last active Oct 13, 2015
Embed
What would you like to do?
【シェルスクリプト】外部サーバーからCSVファイルをダウンロードしてダウンロード元のファイルを削除する方法
#!/bin/sh
USER="username"
PASS="password"
HOST="203.0.113.0"
PORT="22"
DIR="/home/user/csvfile"
sshpass -p "$PASS" ssh -p $PORT $USER@$HOST "cd $DIR && [ -f *.csv ]" &&
sshpass -p "$PASS" scp -P $PORT $USER@$HOST:$DIR/*.csv /csvfile &&
sshpass -p "$PASS" ssh -p $PORT $USER@$HOST "cd $DIR && rm *.csv"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment