CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    May 2001
    Posts
    153

    Passing String b/w Programs

    Hi gurus,

    I am working on two programs that are called by a script (unix shell, or windows batch). The first program ouputs a file. The second program is to consume that file. I need a way to convey the name of the file created by the first progarm, to the second.

    I was thinking of using an environment variable, however, it didn't work, and after I did a search on this forum, found out that it doesn't work (or is very complicated). The suggestion is to use a registry key. My programs, however, are portable, and are mostly going to be used on unix.

    Is there another way I can pass this file name to the second program?

    Thanks in advance.

    Kamran

  2. #2
    Join Date
    Jun 2002
    Location
    Letchworth, UK
    Posts
    1,020
    1) Why not pipe the output of the first program to the second program. That way you won't need to pass filenames.

    2) How about the first program writing the filename to a known file and the second program reading that known file.

    3) Setting environment variables doesn't work because it is set in the shell in which the program was created. Since the shells of the programs do not know about each other, the second programs shell does not know about the first shell's settings.
    Succinct is verbose for terse

  3. #3
    Join Date
    Jan 2001
    Location
    Toronto, Ontario, Canada
    Posts
    62
    I guess you should use message queue for UNIX and write another program which gets whatever is inside the queue and sends to the Windows program.

  4. #4
    Join Date
    May 2001
    Posts
    153
    Thanks for all the replies! This is what I ended up doing:

    1. In the shell, use an environment variable to specify a pre-determined file name
    2. The two programs query the environment variable to pick the file name from. The first program writes to the file, the second reads from it.

    Thanks again,

    Kamran

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured