Skip to content

Instantly share code, notes, and snippets.

@kurozumi
Last active October 13, 2015 04:51
Show Gist options
  • Save kurozumi/dd83118bd25592ca711f to your computer and use it in GitHub Desktop.
Save kurozumi/dd83118bd25592ca711f to your computer and use it in GitHub Desktop.
【シェルスクリプト】外部サーバーから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