-
Notifications
You must be signed in to change notification settings - Fork 3
/
qscp
executable file
·55 lines (54 loc) · 1.23 KB
/
qscp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
# qscp - quick-scp
# Script to help copying a file via scp from one server to another
# input: qscp PATH [DESTINATION_SERVER] [SOURCE_SERVER]
# Parameters:
# PATH: path to a file or directory
# optional:
# DESTINATION_SERVER: change from the default destination server set in .qscprc
# SOURCE_SERVER: change from the default source server (which is local file/localhost)
# Additional settings:
# KEY: ssh key to use
DESTINATION=
SOURCE=
KEY=~/.ssh/id_rsa
EXE=/usr/bin/scp
# Q_PATH - what to quick-scp
Q_PATH=$1
if [ -z $Q_PATH ]; then
echo "Usage: qscp PATH [DESTINATION_SERVER] [SOURCE_SERVER]"
exit
else
if [ -d $Q_PATH ]; then
EXE="$EXE -r"
elif [ -f $Q_PATH ]; then
EXE="$EXE"
else
echo "qscp: file does not exist."
exit 1
fi
Q_PATH=$(readlink -f $Q_PATH)
fi
if [ ! -z $2 ]; then
DESTINATION_SERVER="$2:"
else
DESTINATION_SERVER="$DESTINATION:"
fi
if [ -z $3 ]; then
SOURCE_SERVER="$SOURCE:"
else
SOURCE_SERVER="$3:"
fi
if [ -z $4 ]; then
SSH_KEY=$KEY
else
if [ -f $4 ]; then
SSH_KEY=$4;
else
SSH_KEY=$KEY
fi
fi
EXE="$EXE -i $SSH_KEY"
EXECUTE_STR="$EXE $SOURCE_SERVER$Q_PATH $DESTINATION_SERVER$Q_PATH"
echo "Copying: " $EXECUTE_STR
eval "$EXECUTE_STR"