title: Using a filename with spaces with scp and chmod in bash
body: <p>Periodically, I like to put files in the /tmp directory of my webserver to share out. What is annoying is that I must set the permissions whenever I scp the files. Following the advice from <a href="https://stackoverflow.com/questions/194311/change-permissions-upon-uploading-with-scp">another question</a> I've written a script which copies the file over, sets the permissions and then prints the URL:</p>
  
  <pre><code>#!/bin/bash
  
  scp "$1" SERVER:"/var/www/tmp/$1"
  ssh SERVER chmod 644 "/var/www/tmp/$1"
  echo "URL is: http://SERVER/tmp/$1"
  </code></pre>
  
  <p>When I replace SERVER with my actual host, everything works as expected...until I execute the script with an argument including spaces. Although I suspect the solution might be to use $@ I've not yet figured out how to get a spaced filename to work.</p>