Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 06-21-2014, 08:57 AM   #1
LQ Newbie
Registered: Jun 2014
Posts: 2

Rep: Reputation: Disabled
Processing Piped Data


I've built a proxy using nc and some pipes. What I need to do is process the data coming through that proxy and perform certain actions if conditions are met. For example if a HTTP response code is 200 then run a script perhaps, the data must not be halted in transit. I'm very limited in what I can use, hence using nc for a proxy. Currently I'm piping out the data in transit and reading it from a background process, I'm struggling to capture the data correctly in the background process to be able to process it though.


nc -l -p 9090 <pipe.back | tee pipe.process | nc 9999 >pipe.back

Ideally I would like to be able to process the data and perform actions. Currently it looks like this, I've tried a number of things to store the data in a variable etc but nothing is working.

tee <pipe.process

Any help is much appreciated Thanks, Nick
Old 06-21-2014, 10:23 AM   #2
Senior Member
Registered: Feb 2003
Distribution: debian
Posts: 3,185
Blog Entries: 1

Rep: Reputation: 676Reputation: 676Reputation: 676Reputation: 676Reputation: 676Reputation: 676
I'm not sure if I understand your command. The -l is for listen, but you're piping TO it? Shouldn't the > / < be reversed? Your second nc probably needs a -n before the ip and port values. I use those often to send files between computers without having to setup an ftp server or network share. The down side is having to be near or at both computers or setup a timeout (-w) for that usage. And knowing the name of the filename to write it as on the destination machine. But it can be renamed later.
Old 06-21-2014, 10:36 AM   #3
LQ Newbie
Registered: Jun 2014
Posts: 2

Original Poster
Rep: Reputation: Disabled
The first named pipe is writing back into the nc listener. What the nc listener recieves is being output through the unamed piped and written to pipe.process. This output is also being piped further through another unamed pipe into the nc connection to This connection is writing its responses into pipe.back which in turn are being read by the listener and passed back to the connecting client. I need to process what is being written into pipe.process. To simplify things, I could ask the question "How do I read from a named pipe, process it and execute a script upon a condiction being met?" as i need to process what is passing through the pipe.process named pipe.
Old 06-21-2014, 01:04 PM   #4
Senior Member
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
You are using process substitution in wrong way. Enclose command in braces whose output is to be substituted, as:
nc -l -p 9090 <(pipe.back) | tee pipe.process | nc 9999 > pipe.back


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Problem using piped data as input NirvanaII Programming 13 11-07-2010 07:03 AM
Pipelining data of find command in an array after processing the contents of the data AshishJogeshwar Linux - Software 5 06-10-2010 01:52 AM
Pipelining data of find command in an array after processing the contents of the data AshishJogeshwar Linux - Software 0 06-07-2010 06:15 AM
Processing data from a 'foreign' database with mysql, or tools to pre-process data. linker3000 Linux - Software 1 08-14-2007 08:36 PM
Data Processing joelhop Linux - General 8 01-01-2006 08:08 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:11 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration