DaemonForums  

Go Back   DaemonForums > Miscellaneous > Programming

Programming C, bash, Python, Perl, PHP, Java, you name it.

Reply
 
Thread Tools Display Modes
  #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
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
execute commands from xinitrc rex FreeBSD General 3 22nd October 2008 10:24 PM
Execute a command during login rex FreeBSD General 4 12th September 2008 08:09 PM
Cron won't execute a perl script ivanatora FreeBSD General 4 17th August 2008 07:53 AM
Ruby-gem problem giga FreeBSD Ports and Packages 2 21st July 2008 02:34 PM
Ruby qtruby installation map7 Programming 6 17th July 2008 06:00 AM


All times are GMT. The time now is 03:16 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick