Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR RUBY

ruby run bash command

# Backticks syntax
`echo 'hi'`

# %x() syntax
%x( echo 'hi' )

# Kernel#system
# Executes the given command in a subshell.
system( "echo 'hi'" )

# Kernel#exec
# Replaces the current process by running the given external command.
exec( "echo 'hi'" )

# Open3
require "open3"

Open3.popen3('nroff -man') { |stdin, stdout, stderr| ... }
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #ruby #run #bash #command
ADD COMMENT
Topic
Name
8+6 =