Click to See Complete Forum and Search --> : Passing String b/w Programs


kaftab
July 16th, 2002, 08:44 AM
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

cup
July 16th, 2002, 08:52 AM
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.

charlesdong
July 16th, 2002, 05:51 PM
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.

kaftab
July 30th, 2002, 07:20 AM
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