oldhomemovie
oldhomemovie

Reputation: 15129

Shell execute from Ruby

Assume, I have a file 'text_file.txt' within my .rb script. How do I execute a default windows program for that file from the Ruby?

Upvotes: 1

Views: 2619

Answers (2)

JRL
JRL

Reputation: 77995

From IRB:

system "start text_file.txt"

From a shell:

ruby -e 'system "start text_file.txt"'

Upvotes: 4

wallenborn
wallenborn

Reputation: 4273

Use the system command, like in

ruby -e 'system "ipconfig"'

Upvotes: 0

Related Questions