External prog get file from main dir, want file in diff dir

I am running a external program(2) from another ruby program (1). This
external program requre a local file (the file must lay in the prog 1
dir) . It uses some kind of custom get comand to get this file.

Say my dir is calld TestCase

Then this fle must be in TesCase/file.txt

But i want to store the file in TestCase/CaseX/file.txt (or in some
other folder)

The problem is that i cant change the extern program, and it asks for
the file to be in TestCase folder.

Some code almost similar to the code in the extern program (I cant
change it):
up = some proxy method to connect to user
input up.getfile(“file.txt”)

How do i redirect the extern programs file request to another folder.
And i cant change the externprogram.

Is ther som way to do it, or must i give up and just keep all files
cluttered in the main prog directory?

Dir.chdir() should do what you want, e.g.:

system(“pwd”)
Dir.chdir(“CaseX”) { system(“pwd”) }

Within the block, the working directory is the argument to Dir.chdir.
When the block finishes, the working directory is automatically reset
to what it was before.

  • Jamis

Jamis B. wrote:

Dir.chdir() should do what you want, e.g.:

system(“pwd”)
Dir.chdir(“CaseX”) { system(“pwd”) }

Within the block, the working directory is the argument to Dir.chdir.
When the block finishes, the working directory is automatically reset
to what it was before.

  • Jamis

A million thanks. It worked.