Skip to content

Instantly share code, notes, and snippets.

@KINGSABRI
Created September 27, 2016 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KINGSABRI/d0aade36f31fe02db63247dddcfbdb5f to your computer and use it in GitHub Desktop.
Save KINGSABRI/d0aade36f31fe02db63247dddcfbdb5f to your computer and use it in GitHub Desktop.
#!/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