Posted on: Written by: K-Sato
⚠️ 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).

References

About the author

I am a web-developer based somewhere on earth. I primarily code in TypeScript, Go and Ruby at work. React, RoR and Gin are my go-to Frameworks.