#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2007
    Posts
    5
    Rep Power
    0

    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
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2004
    Location
    Constant Limbo
    Posts
    989
    Rep Power
    363
    Have you looked into Net::SSH?
    Not sure how it would fit your situation as I am a little unclear about your post...
    True happiness is not getting what you want, it's wanting what you've already got.

    My Blog
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2007
    Posts
    5
    Rep Power
    0
    yes I check net/ssh, but it not fit my required. because on my client I run a listener. I think that i miss something with TcpSocket.

IMN logo majestic logo threadwatch logo seochat tools logo