June 17, 2016

Bash Scripts for Transfering Files Between Server and Local Computer

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.


Basically, it's the same as using scp command, but scripts allow you to define short names for servers. For example, instead of username@, or 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 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