Linux sys admin

Hi:
I’m real new to Ruby, and I’m wondering how to call a program like tar
or gzip from a Ruby script. Where can I find documentation for this
sort of thing?

Thanks

Matt

Hi: I’m real new to Ruby, and I’m wondering how to call a
program like tar or gzip from a Ruby script. Where can I
find documentation for this sort of thing?

http://www.rubycentral.com/ref/

http://www.ruby-lang.org/~slagell/ruby/rubyguide.html

To run a command, use Kernel.system (like system(3) in C)

To run a piped command use | as first char in open:

open(“|wc *.c”) do |f|
f.each do |line|
line.gsub(/a+/) do |nam|
puts(nam)
end
end
end

You may also use the low level Kernel.exec with Kernel.fork

see also IO.popen

···

Basile STARYNKEVITCH Basile STARYNKEVITCH
email: basilestarynkevitchnet
alias: basiletunesorg
8, rue de la Faïencerie, 92340 Bourg La Reine, France

Regarding documentation, Hal Fulton’s The Ruby Way has a chapter devoted
to scripting and using Ruby for system administration. Check your local
online bookseller.

···

On Thu, 26 Dec 2002 14:19:52 +0900, Matthew Huggett wrote:

Hi:
I’m real new to Ruby, and I’m wondering how to call a program like tar
or gzip from a Ruby script. Where can I find documentation for this
sort of thing?

Thanks

Matt

Matthew Huggett wrote:

Hi:
I’m real new to Ruby, and I’m wondering how to call a program like tar
or gzip from a Ruby script. Where can I find documentation for this
sort of thing?

Thanks

Matt

For general sys-admin type stuff, also see:

http://ruby-sysutils.sourceforge.net
http://ruby-netutils.sourceforge.net

</shameless plug>

Regards,

Dan