Skip to content

Instantly share code, notes, and snippets.

@rzhw
Created August 24, 2012 11:19
Show Gist options
  • Save rzhw/3449336 to your computer and use it in GitHub Desktop.
Save rzhw/3449336 to your computer and use it in GitHub Desktop.
Basic SSH/SCP use rolled into a Bash function
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