I am using whenever gem. I wanted to set my env variables prior to the scheduled task. The 2nd line in the code below was the command I wanted to run in my schedule.rb file. But looks like I can't get it done so I commented it out and tried in different ways. Still nothing seems to work. Printing env inside the ruby code seems to show the needed variable correctly, but after running 'bundle exec whenever' and checking in the terminal with env command, the variables do not seem to be there. What is wrong here ?
every :hour do
# Run shell script to assign variables and continue the rake task
#system "for line in `cat config/myEnvFile.env` ; do export $line ; done"
f = File.open("config/myEnvFile.env", "r")
f.each_line do |line|
j = line.split(" ")
arr = j.first.split("=")
system "export #{arr[0]}=#{arr[1]}"
system "env"
# This line below is also another way but still nothing works
ENV[arr[0]] = arr[1]
end
rake "task:continue_doing_my_task"
end