I'm uploading a file to a remote server using SCP, but what's the proper way of seeing if that file exists before doing so?
You can't do this with scp. However you can do it with sftp. It would look something like this:
require 'net/sftp'
remote_path = "/path/to/remote/file"
Net::SFTP.start('host', 'username', :password => 'password') do |sftp|
sftp.stat!(remote_path) do |response|
unless response.ok?
sftp.upload!("/path/to/local/file", remote_path)
end
end