Using Ruby to list directory names from a remote machine
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.