Michael Bostler wrote in post #1127833:
> Hey Previn,
>
> I think the issue is that the "system" method runs a command in a
> subshell, and therefore your program's executing environment doesn't
> actually ever change
>
> Check out this link for more info:
> http://stackoverflow.com/questions/2232/calling-bash-commands-from-ruby
>
> Maybe you could achieve what you are looking for by wrapping it in
> another ruby script, ie:
>
> Script 1:
> system "source test.csh && ruby script_2.rb"
>
> Script2:
> puts "a = #{ENV['SYSTYPE']}"

Hi Michael,

With modification as below, it can get right results.

cat script_1.rb
#!/usr/bin/env ruby

system "csh -c 'source test.csh && script_2.rb'"

But I need process it in one file instead of in "script_2.rb", in fact,I 
need source a cshell file(the test.csh here is just a simple example, 
not complete file) to setup env, then start tool accordingly.

So, is there way can source the csh file and still can get the set env 
virables in current shell?

Thanks,
Previn

-- 
Posted via http://www.ruby-forum.com/.