Created
March 12, 2012 09:38
-
-
Save volpe28v/2020932 to your computer and use it in GitHub Desktop.
scpを自動化するスクリプト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
HOST=対象ホスト名(IPアドレス) | |
USER=ログインユーザ | |
PASS=パスワード | |
TARGET_DIR=バックアップディレクトリ(ファイル) | |
BACKUP_DIR=保存先ディレクトリ | |
expect -c " | |
set timeout -1 | |
spawn scp -Cpr ${TARGET_DIR} ${USER}@${HOST}:${BACKUP_DIR} | |
expect { | |
\" Are you sure you want to continue connecting (yes/no)? \" { | |
send \"yse\r\" | |
expect \"password:\" | |
send \"${PASS}\r\" | |
} \"password:\" { | |
send \"${PASS}\r\" | |
} | |
} | |
interact | |
" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
cron や jenkins で動作させる場合は、
interact
↓
expect {"100%" { exit 0 }}
でいけた。