running system commands with ruby
October 18th, 2008 • Uncategorized
# notice the backticks `git config --global user.email`
2 Responses (Add Your Comment)
-
Lukas Rieder October 28, 2008at 1:56 am
October 18th, 2008 • Uncategorized
# notice the backticks `git config --global user.email`
# notice that you can get the stdout of this command
# notice that you can check the $? variable for
# the exist status of your last executed child prozess
output = `git conifg --global user.email`
puts "Hooray, it worked out. Lets make snusu." if $?==0
# notice that you can make your life easier if you
# just want to fire off a command and forget about stdout
puts "No Ruby, no snusnu" if system('git config --global user.email')
And without further ado…
…some crystal clear internet information: http://whynotwiki.com/Ruby_/_Process_management
Cheers, Lukas