I’ve been spending some time playing around with my Raspberry Pi (running Raspbian, an operating system based on Debian) and have set up some virtual servers to enable me to do some local web development. It makes for an easy way to develop as I can host the code in a central location which is easily accessible to all devices on my network. What isn’t so easy however is uploading any finished code to the web server – whilst this is straightforward from my desktop, it’s not so easy from my tablet.

In order to facilitate this I’ve written a bash script which I can easily run from a terminal window which will automatically upload a single file – this is because the website I’m currently working on has a single page, so I only need to upload one file. To do this I’m using the ncftp package which is not installed by default on Raspbian. To install it you need to use the following command from a Raspberry Pi terminal window:

sudo apt-get install ncftp

I then created a simple bash script which uses the ncftpput command to upload a single file. In the following script, change username, password, remote_server, remote_directory and local_file to the correct settings.

ncftpput -u username -p password remote_server remote_directory local_file

I saved my script to my home directory and called it upload.sh, which means in order to run it I simply use the following command:


If you find that this doesn’t work, you need to check that the script can be executed. To do this, use the following command:

sudo chmod +x upload.sh

It’s pretty easy really, but has the potential to be made more powerful if I find myself working on larger websites. ncftpput can upload entire directories and has many other useful features – check the NcFTP website for more details.

Leave a Reply

Your email address will not be published. Required fields are marked *