Created
September 27, 2016 13:59
-
-
Save KINGSABRI/d0aade36f31fe02db63247dddcfbdb5f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'rexec' | |
CLIENT = <<EOF | |
$connection.run do |path| | |
listing = [] | |
IO.popen("ls -la " + path.dump, "r+") do |ls| | |
listing = ls.readlines | |
end | |
$connection.send_object(listing) | |
end | |
EOF | |
command = ARGV[0] || "ruby" | |
puts "Starting server..." | |
RExec::start_server(CLIENT, command) do |conn, pid| | |
puts "Sending path..." | |
conn.send_object("/") | |
puts "Waiting for response..." | |
listing = conn.receive_object | |
puts "Received listing:" | |
listing.each do |entry| | |
puts "\t#{entry}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment