Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

James Robertson http://www.r0bertson.co.uk

« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS 

Using Ruby to list directory names from a remote machine

The first line of code executes an external shell command which retrieves directory names into an array. The second line of code displays each directory making sure to chop the '/', and '\n' from the name.
dir_listing = `ssh 192.168.1.10 'ls */ -d'`
dir_listing.each { |directory| puts directory.chop.chop }

Note: In this example ssh access to the remote machine does not prompt the user for a password as the hosts know each other. see ssh-keygen.

copy files using rsync and ssh

source: http://www.mikerubel.org/computers/rsync_snapshots/#Abstract ; switches: -a = archive mode -e specifies the remote shell to use

rsync -a -e ssh source/ username@remotemachine.com:/path/to/destination/
« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS