Bird
0
0

You want to run a Ruby script data_processor.rb that requires an environment variable DATA_PATH. How do you run it in one command setting the variable temporarily?

hard📝 Application Q8 of 15
Ruby - Basics and Runtime
You want to run a Ruby script data_processor.rb that requires an environment variable DATA_PATH. How do you run it in one command setting the variable temporarily?
Aset DATA_PATH=/tmp/data; ruby data_processor.rb
BDATA_PATH=/tmp/data ruby data_processor.rb
Cruby DATA_PATH=/tmp/data data_processor.rb
Druby -e DATA_PATH=/tmp/data data_processor.rb
Step-by-Step Solution
Solution:
  1. Step 1: Understand setting environment variables temporarily

    In Unix-like terminals, prefixing a command with VAR=value sets the variable only for that command.
  2. Step 2: Identify correct syntax

    DATA_PATH=/tmp/data ruby data_processor.rb runs the script with the variable set temporarily.
  3. Final Answer:

    DATA_PATH=/tmp/data ruby data_processor.rb -> Option B
  4. Quick Check:

    Prefix command with VAR=value to set env var temporarily [OK]
Quick Trick: Prefix command with VAR=value to set env var temporarily [OK]
Common Mistakes:
  • Using Windows 'set' syntax in Unix shell
  • Passing env var as argument to ruby
  • Using ruby -e incorrectly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes