No, you’re not on the wrong blog! I decided to write computer related stuff in English because I’ve seen in my logfiles, that a lot of people from not German-speaking countries visit those computer related topics… The rest of my postings still remains in German.
(Erm, … If you find typos/grammar flaws etc. you can keep them…!)
Uploading and including pictures to a blog is really-nerve wrecking. First you start your ftp client, upload the stuff and finally you have to code some HTML for including the pix to your blog.
Today I got a little pissed about this and I wrote a small script that does all this (more or less) automatically. For this I use a shell command that isn’t available on all linux machines. So, if you want to use that script, you need to install ncftp first. With ncftp another little program will be installed called ncftpput. This one is very handy in scripts, because you can “say” something like that:
ncftpput -u user -p pass ftpserver remote_path local_path/*
Connecting to a ftpserver and uploading all files from local_path to remote_path would be much more complicated with the “ordinary” ftp command, so I use ncftpput.
Now here’s what the script does: First it prepends the current date to all pictures (files) in a given directory. So “example.jpg” becomes “070620_example.jpg”. Then it uploads the files to a given ftp server and produces some HTML code that will include the uploaded pictures to your blog or website. When the upload is complete, the HTML code will be displayed in your favourite editor, e.g. kate. Copy/Paste the code to your blog editor! If you close the editor window, the pictures inside the directory will be deleted.
How to install and use the script: Simply put an empty folder to your desktop, download and copy the script to a place somewhere on your computer and make a desktop shortcut to the script. Don’t forget to right-click to the shortcut and navigate to -> properties -> programs -> advanced and enable “start in terminal”.

(uploadr1.jpg)

(uploadr2.jpg)
Now edit the script, adapt the settings to your needs and start it using the desktop icon. A terminal will pop up, you see some log messages and finally the editor will pop up and you get the HTML.

(uploadr3.jpg)
Done! ![]()
0 Responses to “Shell Script for Uploading Pix to a FTP Server”
Leave a Reply