Simple FTP bash script for uploading images to WeatherUnderground

Here is a simple Linux bash script for uploading images to WeatherUnderground. Backstory and steps at end of post.

if [ -r $MEDIAFILE ]
# File seems to exist and is readable
cd /
put $MEDIAFILE image.jpg

I use BlueIris for my weather camera management. BlueIris is great except that I am limited to one FTP upload per camera. Currently I upload from the BlueIris weather cam to this web site. The challenge I faced was trying to get the image over to WeatherUnderground to see images of the historical forecast.

By using the script above, I am now able to use BlueIris to upload to my web server and then upload from my web server to WeatherUnderground. This solves my single-server upload limitation in BlueIris.

Step by step:

  1. Log in to your Ubuntu/Linux server. If using a gui, launch terminal. I run as interactive root (sudo -i).
  2. Navigate to a script folder. For me this is “cd /usr/local/bin“.
  3. Run nano and your file name. “nano“.
  4. Change the variables in the script above and copy/paste into the nano text editor window.

    1. Note: if you are behind a router or having an issue with NAT (ftp bind error won’t bind to IP x.x.x.x only y.y.y.y), use command “ftp -niv -p” instead of “ftp -n” and test your connection.
  5. ctrl +x” to save
  6. Run “chown non-sudo-user:non-sudo-user“. This changes ownership of the file to your non-sudo user account.
  7. Run “chmod +x“. This makes your script executable.
  8. Run “su username” to run as your camera01p user or other non-sudoer.
  9. Run “crontab -e” and insert the following:
    1. * * * * * /usr/local/bin/
  10. ctrl +x” to save.
  11. Exit out if finished. Type “exit” and press enter.

You should now see your images upload ~every 60 seconds. I was monitoring my firewall logs and observed the connection being made. This confirmed that my script was running as a non-sudo user. I then switched over to WeatherUnderground and my images were being uploaded without problem.

Leave a Reply

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