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

Discussion in 'Ruby' started by Kga Agk, Jun 26, 2009.

  1. Kga Agk

    Kga Agk Guest

    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?
    --
    Posted via http://www.ruby-forum.com/.
    Kga Agk, Jun 26, 2009
    #1
    1. Advertising

  2. Kga Agk

    Jamis Buck Guest

    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

    On Fri, Jun 26, 2009 at 5:36 AM, Kga Agk<> wrote:
    >
    > 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?
    > --
    > Posted via http://www.ruby-forum.com/.
    >
    >
    Jamis Buck, Jun 26, 2009
    #2
    1. Advertising

  3. Kga Agk

    Kga Agk Guest

    Jamis Buck 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.
    --
    Posted via http://www.ruby-forum.com/.
    Kga Agk, Jun 29, 2009
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Cyril Vi?ville

    diff Process under diff users

    Cyril Vi?ville, Jun 29, 2004, in forum: Perl
    Replies:
    1
    Views:
    494
    Joe Smith
    Jun 29, 2004
  2. Berrucho
    Replies:
    2
    Views:
    614
    Infant Newbie
    Dec 5, 2003
  3. A Traveler

    Diff CSS styles for diff INPUT TYPE='s?

    A Traveler, Aug 31, 2004, in forum: ASP .Net
    Replies:
    6
    Views:
    4,901
    Steve Fulton
    Aug 31, 2004
  4. -intl.com
    Replies:
    1
    Views:
    349
    Martin Gregorie
    Oct 22, 2006
  5. Austin Ziegler

    [ANN] Diff::LCS 1.1.0, Diff::LCS 1.0.4

    Austin Ziegler, Aug 8, 2004, in forum: Ruby
    Replies:
    3
    Views:
    174
    Austin Ziegler
    Aug 9, 2004
Loading...

Share This Page