View Single Post
  #1   (View Single Post)  
Old 18th August 2008
Dr_Death_UAE's Avatar
Dr_Death_UAE Dr_Death_UAE is offline
BSD Daemon
 
Join Date: Jul 2008
Posts: 9
Default ruby execute commands remotely

Hi, I was trying to write a small script in ruby that will run specific commands and jobs on my remote server. it work fine but if I define "cmd" with "/bin/sh" to have terminal it doesn't work, any idea?

Code:
#!/usr/bin/ruby

require 'socket'

myhost = ARGV[0]
port = ARGV[1]
cmd = '/bin/sh'

soc = TCPSocket.new(myhost, port)

m = %x[#{cmd}]
soc.puts m

soc.close
__________________
Theory is when you know all and nothing works.
Practice is when all works and nobody knows why.
In this case we have put together theory and practice: nothing works... and nobody knows why!
(Albert Einstein)
Reply With Quote