xref: /btstack/doc/manual/mirror_file_sftp.sh (revision 7cf4e7c503d012a7e36b7af217511651c6521f0b)
1*7cf4e7c5SMatthias Ringwald#!/bin/bash
2*7cf4e7c5SMatthias RingwaldUSAGE="Usage: mirror_file_sftp.sh user@host local_path remote_path"
3*7cf4e7c5SMatthias Ringwald
4*7cf4e7c5SMatthias Ringwald# command line checks, bash
5*7cf4e7c5SMatthias Ringwaldif [ $# -ne 3 ]; then
6*7cf4e7c5SMatthias Ringwald        echo ${USAGE}
7*7cf4e7c5SMatthias Ringwald        exit 0
8*7cf4e7c5SMatthias Ringwaldfi
9*7cf4e7c5SMatthias Ringwalduser_host=$1
10*7cf4e7c5SMatthias Ringwaldlocal_path=$2
11*7cf4e7c5SMatthias Ringwaldremote_path=$3
12*7cf4e7c5SMatthias Ringwald
13*7cf4e7c5SMatthias Ringwaldecho Mirroring file ${local_path} to ${user_host}:${remote_path}
14*7cf4e7c5SMatthias Ringwald
15*7cf4e7c5SMatthias Ringwald# SFTP is very peculiar: recursive put only works for a single directory
16*7cf4e7c5SMatthias Ringwald# note: does not work with sftp of OS X 10.11
17*7cf4e7c5SMatthias Ringwaldsftp ${user_host} << EOF
18*7cf4e7c5SMatthias Ringwald  put ${local_path} ${remote_path}
19*7cf4e7c5SMatthias Ringwald  quit
20*7cf4e7c5SMatthias RingwaldEOF
21*7cf4e7c5SMatthias Ringwaldrm -rf tmp/${folder}
22