Bash File Backup via SSH

I am trying to make a bash script that will transfer a file from my machine to a server maintained by my school that is used to back up code. It is a hassle to transfer the file manually every single time that I want to make the transfer.

Some applications, like TextWrangler, have the ability to save to server. However, I would rather be able to do it quickly from terminal.

Where would I go from here? Would I need to somehow pass in the file I'd like to send as a parameter? Is there a way to make sure that it goes to the correct directory?

#!/bin/bash
# This should log me into orca
# http://aruljohn.com/info/filetransfer/
# http://stackoverflow.com/questions/1895185/how-to-ssh-from-within-a-bash-script
sftp username@place
expect "username@place password: "
sleep 1
send "mypassword"

Answers


Why not use "scp" secure copy instead of sftp.

You don't need "expect" to run this, and, if you configure the remote/local certificates properly you will not need to mess with passwords.

See some examples of how simple it can be. And the full how to docs.


Need Your Help

interface and abstract class implementation

java

Just as all subclasses which extend from an abstract class must provide implementation for all abstract methods, do all methods of an interface must do the same for all methods which implement them?

How to ensure display of overlays in iOS MapKit

ios mkmapview overlay mapkit

I've looked at several StackOverflow posts and Apple documentation on how to implement overlays in MKMapView. For me, I'm interested specifically in displaying MKPolygon objects on my map. I've found