There is a command I want to call that returns a string, I want to call this command while inside a ruby script, and have access to the result.
+2
A:
I am assuming by command you mean an OS command.
# this will execute ls and assign the dir listing to the variable
dir_list = `ls`
os_user = `whoami`
KandadaBoggu
2010-03-03 22:14:20
KandadaBoggu, it's you! You beat me to it! (+1)
macek
2010-03-03 22:16:42
@smotchkkiss Low hanging fruit :-). Damn this game is addictive.
KandadaBoggu
2010-03-03 22:21:46
A:
you have the method Kernel#system
too http://ruby-doc.org/core/classes/Kernel.html#M005971
system "dir"
shingara
2010-03-03 23:12:37