pipe

How does one use the wait() function when forking multiple processes?

Hi all, Learning to use the fork() command and how to pipe data between a parent and it's children. I am currently trying to write a simple program to test how the fork and pipe functions work. My problem seems to be the correct use/placement of the wait function. I want the parent to wait for both of its children to finish processing. ...

What's the advantage of queues over pipes when communicating between processes?

What would be the advantage(s) (if any) of using 2 Queues over a Pipe to communicate between processes? I am planning on using the multiprocessing python module. ...

Pipe output of a command to an interactive python session?

What I'd like to do is something like $echo $PATH | python --remain-interactive "x = raw_input().split(':')" >>> >>> print x ['/usr/local/bin', '/usr/bin', '/bin'] I suppose ipython solution would be best. If this isn't achievable, what would be your solution for the situation where I want to process output from various other comm...

Preserve colouring after piping grep to grep

There is a simlar question in Preserve ls colouring after grep’ing but it annoys me that if you pipe colored grep output into another grep that the coloring is not preserved. As an example grep --color WORD * | grep -v AVOID does not keep the color of the first output. But for me ls | grep FILE do keep the color, why the difference ? ...

Pipe Java to Grep: Why not working?

I am trying to run this dreadfully simple command in Bash java -cp nasa-top-secret.jar gov.nasa.RocketToMoon | grep -v codehaus but grep is not working (it does not filter out my string). How can I filter my java output using grep? ...

How to pipe stderr, and not stdout?

I have a problem that writes information to stdout and stderr, and I need to grep through what's coming to stderr, while disregarding stdout. I can of course do it in 2 steps: command > /dev/null 2> temp.file grep 'something' temp.file but I would prefer to be able to do is without temp files. Any smart piping trick? ...

Capture console text of piped app to another app

I'm sorry if the title is quite confusing but I am wondering if it's possible to get the stdout of an app that is piped into another app in java. Here's the commandline. sox -d -t wav - | lame - test.mp3 If this is executed in bash, this is the output. Input File : '/dev/dsp' (ossdsp) Channels : 2 Sample Rate : 48000 Pr...

Why would Linux reuse a file descriptor allocated by pipe()

I'm seeing an issue using both sockets and pipes in Linux. Specifically, we call pipe(), which allocates the next two available file descriptors... let's say 10 and 11. Then we call accept() on a socket, expecting it to allocate 12. Instead, it allocates 11. We've tested a bit, and it seems the second FD returned from pipe() is alway...

ftp client controlled by pipe in C

Hi! I am trying to control ftp client from C program (OS X). I did fork and execve - process is started ok. The problem is with pipes - I can send command to ftp client process and get feedback from it just fine (If i send "help\n" i get back help output) but what I never get in pipe is "ftp> " prompt. Any ideas? Ivan ...

gawk / awk: piping date to getline *sometimes* won't work

Hi! I'm attempting to convert dates from one format to another: From e.g. "October 29, 2005" to 2005-10-29. I have a list of 625 dates. I use Awk. The conversion works -- most of the time. Hovewer, sometimes the conversion won't happen at all, and the variable supposed to hold the (converted) date remains undefined. This always happen...

php extract image from piped email

This is an extension to a question which I asked some time ago. I am now interested in trying to get images out of an email piped to a php script. Where are they stored, or would they have to be decoded from the email? I know there are imap functions but can they be used reading from stdin. I really no nothing, any help would be apprec...

Getting readline to block on a FIFO

I create a fifo: mkfifo tofetch I run this python code: fetchlistfile = file("tofetch", "r") while 1: nextfetch = fetchlistfile.readline() print nextfetch It stalls on readline, as I would hope. I run: echo "test" > tofetch And my program doesn't stall anymore. It reads the line, and then continues looping forever. Why w...

Behavior of a pipe after a fork()

When reading about pipes in Advanced Programming in the UNIX Environment, I noticed that after a fork that the parent can close() the read end of a pipe and it doesn't close the read end for the child. When a process forks, does its file descriptors get retained? What I mean by this is that before the fork the pipe read file descriptor...

Why does fprintf start printing out of order or not at all?

This code should take an integer, create pipes, spawn two children, wait until they are dead, and start all over again. However, around the third time around the loop I lose my prompt to enter a number and it no longer prints the number I've entered. Any ideas? #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <errno...

Pipe transfer blocks when writing object with small pipe size

Hi everyone, I'm having a bit of problem with an example I'm currently testing. For some reason, the execution blocks when writing at oos.writeObject(new SimpleObject());, despite that fact that the pipe should transfer the data across, even (I'd assume) if it had to do it in smaller operations due to a small pipe size. Anyway, the examp...

libevent buffered events and half-closed sockets

It is simple to implement a TCP port mapper using bufferevent_* functions of libevent. However, the documentation states that "This file descriptor is not allowed to be a pipe(2)" and I doubt if it can handle the case of when we can only read or only write to a file descriptor. Will libevent work correctly if the socket is shutdown in ...

How could I stop PHP from returning headers when executed from commandline?

This may be a ridiculous question, but it's been bothering me for a while. I have a mail forwarder piped to a PHP script, it receives perfectly, however I have the following error mailed back to me instantly: A message that you sent could not be delivered to one or more of its recipients. This is a permanent error. The following address...

[UNIX] Is it safe to pipe the output of several parallel processes to one file using >> ?

I'm scraping data from the web, and I have several processes of my scraper running in parallel. I want the output of each of these processes to end up in the same file. As long as lines of text remain intact, I the order of the lines does not matter. In UNIX, can I just pipe the output of each process to the same file using the >> ope...

How do I declare a pipe in a header file? (In C)

I have an assignment in which I need to declare a pipe in a header file. I really have no idea how to do this. It might be a really stupid question and I might be missing something obvious. If you could point me in the right direction I would greatly appreciate it. Thanks for your time. EDIT: Sorry about the question being so vague. M...

How to rate-limit a pipe under linux ?

Is there a filter which I could use to rate-limit a pipe on linux? If this exists, let call it rate-limit, I want to be able to type in a terminal something like cat /dev/urandom | rate-limit 3 -k | foo in order to send a a stream of random bytes to foo's standard input at a rate (lower than) 3 kbytes/s. ...