PDA

View Full Version : executing shell commands with ruby??


pranith
September 7th, 2005, 10:22 AM
hi,
Is there ne module in ruby that executes linux shell commands
I tried with exec() but it terminates the program just after the exec("<linux command>") part is completed it will not execute the remaining part of the ruby program so what shud I do?? Is there a better module?? or shuld we modify exec()
anticipating help
thanks
bye
pranith

wtd
September 7th, 2005, 03:28 PM
You can either use the "system" method to simply run the command...

system "ls"

Or you can use backticks to capture the output of the program.

ls_results = `ls`

pranith
September 7th, 2005, 10:58 PM
thanks
thank u very much

pavel989
December 13th, 2007, 06:36 PM
oh wow, like an hour of googling and its that simple? thanks very much (i love ruby!)