pipes

How can a console application (e.g. Java) recognize the source of the 'standard input' stream?

If I run 'python' on the linux command line, and I don't provide any command line arguments, the program displays a welcome message and waits for user input. I would assume that under the hood, the program sends the message to the 'standard output' stream and performs a blocking read on the 'standard input' stream. If, however, I invoke...

How can I pipe the output of a program that can only write to a file (and not to STDOUT)?

I'm trying to write something like Perl Audio Converter, so I need to be able to decode every relevant audio format to wav (PCM) and then encode wav to every relevant audio format. I'd like to do this in parallel, by piping the output of the decoder directly to the input of the encoder. Most decoders have an option to decode to stdout, b...

How to use Regex to Find & Replace html table tags?

I have blocks of code that look like this: <table border="0"><tr><td><img src='http://profile.ak.fbcdn.net/object3/686/9/q142163634919_249.jpg'/&gt;&amp;nbsp;&amp;nbsp;&lt;/td&gt;&lt;td&gt;Gift of Life Marathon Blood Drive - "the group stood before a sea of 1,000 Long Trail Brewing Co. pint glasses..." (Rutland Herald, VT)</td></tr></t...

Piping Cygwin into a Python program

Hello guys, As a i'm new to the whole Piping thing and Python I had recently encountered a problem trying to pipe Cygwin's stdin & stdout into a python program usin Python's subprocess moudle. for example I took a simple program: cygwin = subprocess.Popen('PathToCygwin',shell=False,stdin=subprocess.PIPE,stdout=subprocess.PIPE) cygwin.s...

Using Windows named pipes from inside activeX control - Possible?

Hi All, I am starting to design a DMO to run from inside a windows media player activeX control in Internet Explorer. is there any reason why using windows named pipes from inside the DMO wouldn't work? user permissions/privilages/ kernel mode stuff? Thanks :) Roey ...

Howto pipe raw PCM-Data from /dev/ttyUSB0 to soundcard?

Hi I'm working currently on a small microhpone, connected to PC via an FPGA. The FPGA spits a raw datastream via UART/USB into my computer. I'm able to record, play and analyze the data. But I can't play the "live" audiostream directly. What works is saving the datastream in PCM raw-format with a custom made C-program, and piping the ...

python web app logging through pipe? (performance concerned)

I'm writing a web app using python with web.py, and I want to implement my own logging system. I'd like to log detailed information about each request that come to python (static files are handled by web servers). Currently I'm thinking about writing the logs to a pipe. On the other side, there should be cronolog. My main concern is th...

Pipe communication C++

I´m writing two litle c++ apps that must communicate. First one will be a service which, every once in a while, must alert the user for something. Since a service cannot create windows I designed the app to be two separate executables. The service will use a notifier to communicate. The service needs only to send text messages to the n...

Python popen wont work with block devices

I am wring a small forensic app which looks like this so far import time, os,sys def getter(): filename = sys.argv[1] print "File Entered: " + filename os.system('file ' + filename) print "\n" pipe = os.popen("xxd " + filename, "r") print pipe.read() I input via the command line a file and it prints out the t...

CreateProcess with redirection access denied on the output pipe

Hello: I have a simple code running in a DLL called from MFC application. Generally it implements the example that is shown in msdn article - http://msdn.microsoft.com/en-us/library/ms682499%28VS.85%29.aspx. Except I just want to create any process (say shell script). All the process creation is done fine with no errors. However, ReadFi...

Performance of sockets vs pipes

I have a Java-program which communicates with a C++ program using a socket on localhost. Can I expect to gain any performance (either latency, bandwidth, or both) by moving to use a native OS pipe? I'm primarily interested in Windows at the moment, but any insight related to Unix/Linux/OSX is welcome as well. EDIT: Clarification: both ...

Handling streamed data via pipes

A Win32 application (the "server") is sending a continuous stream of data over a named pipe. GetNamedPipeInfo() tells me that input and output buffer sizes are automatically allocated as needed. The pipe is operating in byte mode (although it is sending data units that are bigger than 1 byte (doubles, to be precise)). Now, my question i...

Creating a feed from a list of links in yahoo pipes

Hi, I was trying to get a custom RSS feed to use with the MiroTV app - an application that gets video from an RSS feed and download it so you can watch it in your pc. I mostly use MiroTV to watch video lectures from sites that already a nice rss feed for their lectures like Yale Open Courses. I learned about Yahoo! Pipes recently and ...

Basic Questions about Pipes

Hi, I have some basic questions about pipes I am unsure about. a) What is the standard behavior if a process writing to a pipe gets killed (ie. SIGKILL SIGINT) Does it close the pipe? Does it flush the pipe? Or is the behavior undefined? b) What is the standard behavior if a process returns normally? Is it guaranteed to flush the p...

minor issue with fork() and pipe()

I 'm writing a little program that implements pipes like they work in the shell. ie: ls -hal | sort | grep p | wc it works fine, with the minor issue that on one line, when CMD_NO=n, the comparison i biggerthan CMD_NO does not work, but i!=(CMD_NO-1) does. I'm trying to figure out why in this particular case (the line is ocmmented a...

AWK: Assigning system command's output to variable

Hi, I want to run the system command in a awk script and get its output stored in a variable. I've been trying to do this, but the command's output always goes to shell and I'm not able to capture it. Any ideas on how this can be done? Example: $ date | awk --field-separator=! {$1 = system("strip $1"); /*more processing*/} Should ...

Capturing program output.

i am making a small library that will basically capture the standard outputs of a program (such as printf()) into a separate process/thread...this process should then perform certain tasks (lets say write these captured outputs to a file)...i am just beginning to do serious C programming so i am still learning. i wanted to know what is ...

When the input is from a pipe, does STDIN.read run until EOF is reached?

Sorry if this is a naïve question, but let's say I have a Ruby program called processor.rb that begins with data = STDIN.read. If I invoke this program like this cat textfile.txt | processor.rb Does STDIN.read wait for cat to pipe the entire textfile.txt in? Or does it assign some indeterminate portion of textfile.txt to the data vari...

writing stdin into a file with fwrite()

I have to capture the stdout in a program and write that into a file...so I created a pipe. In the parent process, I captured the stdout in the pipe using dup() and I need to get this into a file...so I did a dup() in the child to get the captured file descriptor into the stdin. Now, how do I write this stdin into a file using fwrite()?...

Retrieving the output of subprocess.call()

How can I get the output of a process run using subprocess.call()? Passing a StringIO.StringIO object to stdout gives this error: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py", line 444, in call return Popen(*popenargs,...