Yes, Bash scripts again! Two scripts for copying files from server to local computer and vice versa. Usually I use them if I want to work with some text files in graphical editors, not in Vim. So I can download the file to my local computer and then upload it back to the server.
./copy-file-from-server.sh [SERVER] [FILE]
./copy-file-to-server.sh [SERVER] [FILE]
Basically, it's the same as using
scp
command, but scripts allow you to define short names for servers. For example, instead of username@192.168.1.1
, username@some.hostname.com
or something1-23-45-678-9.eu-east-0.compute.amazonaws.com
you can use short names, like test
, demo
, latest
etc.To set your own hosts in the script you need to modify function
setHost()
. In the copy-file-from-server.sh
script you can also set a fixed directory where you want to download files. Currently it downloads to the same directory where script was run, but you can change it in the downloadFile()
function.Also, don't forget about
aliases
! You can set some short name to the script and use it in every directory.
No comments:
Post a Comment