Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I come primarily from a Windows background, migrating over to Mac. I've used WinSCP and loved a featured called "Keep Remote Directory Up To Date".

Here's the question: is there an equivalent SCP client for OSX that will monitor a directory for changes and upload when detected? I don't care if it's a GUI client or via command-line (rsync, ssh, etc).

share|improve this question
add comment

5 Answers

up vote 0 down vote accepted

Your best bet is probably to use Folder Actions and adapting the new item alert script to your needs, issuing a call to the command line utility of your choice.

share|improve this answer
add comment

Check out Transmit by Panic. From one of their blog posts, a commenter said:

One of my favorite features, that some people may not know, when you open a document into a certain application in Transmit (let’s say an .html file into BBEdit) then edit the document and Save it; Transmit automatically uploads it back to the server to the same file, no questions asked. It works wonders when making websites and editing CSS. Also convenient to make small corrections in images through Photoshop. You can also handle how Transmit deals with certain file extensions through the Prefs.

share|improve this answer
    
I've looked into Transmit - unfortunately it doesn't support SCP - only SFTP connections. Also, Transmit refuses to open my private key files. –  pygorex1 Jan 12 '11 at 2:24
    
This feature is something different. It just means you can directly edit files from the remote server using the editor of your choice. Other FTP programs also support this. –  Daniel Beck Jan 12 '11 at 5:38
add comment

I have come across a ruby script that does what you need, but it will take a little adapting.

Description:
rsync whenever the directory the script is in changes using the OS X FSEvents API https://gist.github.com/149491

share|improve this answer
add comment

You may use launchd instead of folder actions (to get some sample code just google for: launchd folder watcher).

You may then combine you launchd folder watcher item with a scp script similar to this one.

Or, use rsync over ssh like so:

rsync -urltv --delete -e ssh /path/to/dir othermachine:/path/to/dir

For a commercial cross-platform software solution see GoodSync.

share|improve this answer
add comment

Well, I had the same kind of problem and it is possible using these together: rsync, SSH Passwordless Login, Watchdog (a Python sync utility) and Terminal Notifier (an OS X notification utility made with Ruby. Not needed, but helps to know when the sync has finished).

  1. I created the key to Passwordless Login using this tutorial from Dreamhost wiki: http://cl.ly/MIw5

    1.1. When you finish, test if everything is ok… if you can't Passwordless Login, maybe you have to try afp mount. Dreamhost (where my site is) does not allow afp mount, but allows Passwordless Login. In terminal, type:

    ssh [email protected] You should login without passwords being asked :P

  2. I installed the Terminal Notifier from the Github page: http://cl.ly/MJ5x

    2.1. I used the Gem installer command. In Terminal, type:

    gem install terminal-notifier

    2.3. Test if the notification works.In Terminal, type:

    terminal-notifier -message "Starting sync"

  3. Create a sh script to test the rsync + notification. Save it anywhere you like, with the name you like. In this example, I'll call it ~/Scripts/sync.sh I used the ".sh extension, but I don't know if its needed.

    #!/bin/bash terminal-notifier -message "Starting sync" rsync -azP ~/Sites/folder/ [email protected]:site_folder/ terminal-notifier -message "Sync has finished"

    3.1. Remember to give execution permission to this sh script. In Terminal, type:

    sudo chmod 777 ~/Scripts/sync.sh 3.2. Run the script and verify if the messages are displayed correctly and the rsync actually sync your local folder with the remote folder.

  4. Finally, I downloaded and installed Watchdog from the Github page: http://cl.ly/MJfb

    4.1. First, I installed the libyaml dependency using Brew (there are lot's of help how to install Brew - like an "aptitude" for OS X). In Terminal, type:

    brew install libyaml

    4.2. Then, I used the "easy_install command". Go the folder of Watchdog, and type in Terminal:

    easy_install watchdog

  5. Now, everything is installed! Go the folder you want to be synced, change this code to your needs, and type in Terminal:

      watchmedo shell-command
          --patterns="*.php;*.txt;*.js;*.css" \
          --recursive \
          --command='~/Scripts/Sync.sh' \
          .
    

    It has to be EXACTLY this way, with the slashes and line breaks, so you'll have to copy these lines to a text editor, change the script, paste in terminal and press return.

    I tried without the line breaks, and it doesn't work!

    In my Mac, I always get an error, but it doesn't seem to affect anything:

    /Library/Python/2.7/site-packages/argh-0.22.0-py2.7.egg/argh/completion.py:84: UserWarning: Bash completion not available. Install argcomplete.

    Now, made some changes in a file inside the folder, and watch the magic!

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.