Created
August 24, 2012 11:19
-
-
Save rzhw/3449336 to your computer and use it in GitHub Desktop.
Basic SSH/SCP use rolled into a Bash function
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
cse_func() | |
{ | |
host='username@hostname' | |
if [ "$1" == 'push' ] ; then | |
location=$2 | |
files=`echo "$@" | cut -d' ' -f3-` | |
scp $files $host:"$location" | |
elif [ "$1" == 'pull' ]; then | |
if [ $# -gt 3 ]; then | |
echo "$0: to pull multiple files, write \{remote-file1,remote-file2,...\}" | |
else | |
restofcommand=`echo "$@" | cut -d' ' -f2-` | |
scp $host:$restofcommand | |
fi | |
else | |
if [ $# -gt 0 ]; then | |
echo "$0: unknown action $1" | |
else | |
ssh $host | |
fi | |
fi | |
return 0 | |
} | |
alias cse=cse_func |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment