Jim <jovecka / dallas.net> writes:

> I would like to use Ruby to call commands, e.g. "find , perl scripts  ,
> nmap , and others" is this
> possible?

You have several options.


The 'system' method invokes a command, waits for it to complete, and
lets you access the exit status.

   system("mt rewind")


A string in backticks, or quoted using %x{xxx} is executed, and the
standard output is returned to the caller.

   users = `who`

   users = %x{who}

Finally, you can open a pipe are read and write to a shell subprocess:

   IO.popen("ps ax") do |pipe|
     while pipe.gets
       print if /httpd/
     end
   end


(or, in a more Rubyish style:

   puts IO.popen("ps ax").select { |line| line =~ /httpd/ }



Regards


Dave