⚠️ This article was posted over 2 years ago. The information might be outdated. ⚠️
Table of Contents
The Ruby System Method
Use system
or exec
to run cli commands from Ruby programs.
# test.rb
def show
system 'ls'
exec 'pwd'
end
show
If you run the program below, it would output the list of directories and files(ls
) and the current working directory(pwd
).