E
Esen Sagynov
Hi,
Some very weird behavior is happening with Ruby when I run the code with
"sudo" command.
Let's say I have the following code in "myex.rb" source file:
-----------------------------
if ENV["CUBRID"]
puts "ENV[CUBRID] is: '#{ENV["CUBRID"]}'"
else
puts "$CUBRID_BROKER is not defined. Possibly you have not installed
CUBRID Database yet."
end
-----------------------------
I have installed the CUBRID Database, and when I run the code by typing
"ruby myex.rb" I correctly receive the path where CUBRID has been
installed.
-----------------------------
ENV[CUBRID] is: '/home/esen/programfiles/CUBRID'
-----------------------------
However, when I run this code with "sudo" at the beginning like "sudo
ruby myex.rb", the "ENV['CUBRID']" is actually nil, thus, returns the
second string in the else block.
Can anyone explain why "sudo" neglects all ENVironmental variables?
Some very weird behavior is happening with Ruby when I run the code with
"sudo" command.
Let's say I have the following code in "myex.rb" source file:
-----------------------------
if ENV["CUBRID"]
puts "ENV[CUBRID] is: '#{ENV["CUBRID"]}'"
else
puts "$CUBRID_BROKER is not defined. Possibly you have not installed
CUBRID Database yet."
end
-----------------------------
I have installed the CUBRID Database, and when I run the code by typing
"ruby myex.rb" I correctly receive the path where CUBRID has been
installed.
-----------------------------
ENV[CUBRID] is: '/home/esen/programfiles/CUBRID'
-----------------------------
However, when I run this code with "sudo" at the beginning like "sudo
ruby myex.rb", the "ENV['CUBRID']" is actually nil, thus, returns the
second string in the else block.
Can anyone explain why "sudo" neglects all ENVironmental variables?