[CALUG] moving data from program to program

Jim Bauer jfbauer at comcast.net
Fri Oct 23 20:59:35 EDT 2009


If I am reading this right you want two programs, prog1 and prog2, that
each generate lines of text.  And a third program, prog3, that reads all
its data from stdin but gets the 1st line from prog1, 2nd line from
prog2, 3rd line from prog1,.....  If that is an accurate assessment,
then something line this might work.

awk -v f2=<(prog1) '
    {
        print $0;
        getline < f2;
        print $0;
    } ' <(prog2)  | prog3

Note that this will have issues it the two programs (prog1 & prog2) do
not generate the same number of lines.



Walt Smith wrote:
> hi Jim,
> 
> thanks for the try and link.
> The article discusses multiple outputs rather than inputs.
> And I may well need to output multiple data to examine intermediate
> results. I can easily redirect output to tabs in a gui term.
> 
> However, I was looking for a way to do  *multiple data line input*
> to a program on a BASH line. Said differently, one line from one source
> and another line from another source. I'm wondering where all the BASH 
> programmers went ?  In  this case, a program sends one string of data, and
> a CSV files ships out another line to "Process_Data".
> 
> I mucked around awhile and have a somewhat incomplete solution.
> I have a little more work to do.
> 
> If there are any BASH people out there, comments appreciated..
> The names are changed to reflect actual work performed for 
> the convenience of any reader ...  from my real names.
> 
> One might groan over the "sleep"... but I'm still wrestling this.
> 
> I'm still not clear about the operation of tee in combination
> with multiple pipes...   i.e. how many pipes will the data continue
> to pump itself thru ..? And how to stop one and let another thru.
> 
> And yes, I'm also considering writing data to temporary files
> and environment variables. And using options on the command line.
> I'd prefer to look at this pipe/tee method first however.
> 
> THX !!  ( the following is all one line )
> =================
>  my_port=`ps | mono Parse_unix_ps.exe`; mono Create_Data.exe | tee  $my_port | grep , | tee >(cat amplitude_offset_128.csv) | mono data_processing.exe ; sleep 2s|tee >(mono Convert_Data.exe)
> 
> 
> Walt..........
> 
> ==================
> 
> This article might help:
> 
>   http://www.codeproject.com/KB/cpp/MultipleConsoles.aspx
> 
> Later . . .   Jim
> 
> 
> Walt Smith wrote:
>> hi,
>>
>> Looking for an idea.
>> I have some small standalone C# programs done in
>> mono on linux. 
>>
>> prob:
>>
>> I want to create data in Prgm1.
>> I want to create data in Prgm2.
>> I want "Data_Processor" to get the data from ** both **,
>> one after the other using Console.ReadLine.
>>
>> Data itself is obviously one string (the ReadLine)
>> but inside is actually an array of double which can be 64 to
>> say 4096 doubles long-- prefer capabilty to be longer.
>> Prefer to stay with transporting one long string.
>>
>> setup:
>>  
>> I prefer to use a Console.WriteLine to send
>> data to the terminal and to use Console.ReadLine
>> to get the data.  I like to use CL pipe and tee to do
>> prgm to prgm data xfer and (some) user IO in the first prgm.  
>> Data moved is generally an array of doubles.   Often I will 
>> cut the data displayed 
>> in the terminal and paste it into  OO calc.
>>
>>
>> If it can't be done easily in the term in command line,
>> I'm will to entertain other "ideas".
> 




More information about the CALUG mailing list