Run a script within

hello,

I want to run a script within a script.
Therefor I use the ``system´´ command.

The second script I want to start is in a different
directory and loads a file with load´´, i.e.load './abc.inc.rb’´´ (this file is in the same, diff.
dir).

My problem is, the second script throw an error,
that the load-cmd fail - the file ``abc.inc.rb´´ was
not found.

I’v changed the ?: variable, but the error is already
there.

How to solve this problem?

I’v tried to use the -Cdirectory argument of the ruby
interpreter. But the interpreter always say ``cannot cd to
this dir…´´ (in the ruby c-sources I haven’t found the
fn to check this… [where is this part of the source?]).

…I use Win32.

daniel

“daniel” offstuff@aon.at schrieb im Newsbeitrag
news:3e9527ac$0$16258$91cee783@newsreader01.highway.telekom.at…

I want to run a script within a script.
Therefor I use the ``system´´ command.

I’d prefer to use Kernel.load() if possible. Try this:

def Kernel.chdirAndLoad( dir, file, wrap=false )
oldPwd = Dir.pwd

begin
Dir.chdir( dir )
Kernel.load( file, safe )
ensure
Dir.chdir( oldPwd )
end
end

puts “PWD = #{Dir.pwd}”

Kernel.chdirAndLoad(
“C:\Programme\GNU\CygWin\home\Administrator\bin\test”,
“load-test-loaded.rb” )

puts “PWD = #{Dir.pwd}”

Cheers

robert