The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
function and pipe Orbix UNIX for Dummies Questions & Answers 2 01-01-2008 12:57 AM
Replace a Pipe with tab srikanthus2002 Shell Programming and Scripting 1 04-25-2007 03:22 AM
Named PIPE Tamil UNIX for Dummies Questions & Answers 2 01-17-2007 12:20 AM
Problem with pipe into sed 98_1LE Shell Programming and Scripting 2 08-13-2005 01:40 PM
pipe help bb666 High Level Programming 5 02-26-2002 01:07 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 02-15-2004
Registered User
 

Join Date: Feb 2004
Posts: 12
PIpe Spy

Im trying to get my program to behave in this way:

prog 1 | ./pipespy myfile.dat | prog2

the standard output of prog1 is supplied as the input to prog2 and copied into file myfile.dat.

need help
Reply With Quote
Forum Sponsor
  #2  
Old 02-15-2004
oombera's Avatar
Registered User
 

Join Date: Aug 2002
Location: Cleveland, OH
Posts: 804
You want the tee command.
Code:
prog 1 | tee myfile.dat | prog 2
If you want to append to myfile.dat, use:
Code:
prog 1 | tee -a myfile.dat | prog 2
What's PipeSpy btw?
Reply With Quote
  #3  
Old 02-16-2004
Registered User
 

Join Date: Feb 2004
Posts: 12
pipespy is a C++ program i was thinking of writing.
you prog1 and prog2 what type of files should it be? like should it be a C++ program,or just like text file?
Reply With Quote
  #4  
Old 02-16-2004
oombera's Avatar
Registered User
 

Join Date: Aug 2002
Location: Cleveland, OH
Posts: 804
Quote:
Originally posted by jodders
you prog1 and prog2 what type of files should it be? like should it be a C++ program,or just like text file?
Prog1 and Prog2 are any program (such as c++) or script(which is a text file) you want them to be... as long as Prog1 would normally send output to the screen, my line of code will redirect it into "myfile.dat" and also send it to "Prog2".
Reply With Quote
  #5  
Old 02-17-2004
Registered User
 

Join Date: Jan 2002
Location: India
Posts: 111
Perhaps it could work out this way:

prog 1 | ./pipespy myfile.dat | prog2


The executable 'pipespy' should read the standard input and before writing the data to standard output store it within a file named 'myfile.dat'
__________________
Regards,
Satya Prakash Prasad
Reply With Quote
  #6  
Old 02-17-2004
Registered User
 

Join Date: Jul 2002
Location: new york
Posts: 1,025
Quote:
you prog1 and prog2 what type of files should it be?
these can be any executables. see the man pages for 'tee' and it gives a simple example using grep and wc.
Reply With Quote
  #7  
Old 02-17-2004
Registered User
 

Join Date: Feb 2004
Posts: 12
hey guys,thanks for a all your help,but i cant seem to get it working.i created prog1 and prog2 has a .txt file,and i keep getting

aspasia$ prog1.txt | tee -a myfile.dat | prog2.txt
-bash: prog1.txt: command not found
-bash: prog2.txt: command not found


any suggestions?
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 05:47 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0