Все вопросы: [pipe]

169 вопросов

34
голосов
11ответов
22149 просмотров

blocks - send input to python subprocess pipeline

I'm testing subprocesses pipelines with python. I'm aware that I can do what the programs below do in python directly, but that's not the point. I just want to test the pipeline so I know how to use it. My system is Linux Ubuntu 9.04 with default python 2.6. I started with this documentation ex...

0
голосов
1ответов
2860 просмотров

Java: dealing properly with pipes as stdin

I get a weird error ("The process tried to write to a nonexistent pipe.") if I stop reading from piped input, from a program that works fine for non-piped input. How can I avoid causing this error? code: package com.example.test; import java.io.BufferedReader; import java.io.IOException; impor...

42
голосов
14ответов
5667 просмотров

Why don't I see pipe operators in most high-level languages?

In Unix shell programming the pipe operator is an extremely powerful tool. With a small set of core utilities, a systems language (like C) and a scripting language (like Python) you can construct extremely compact and powerful shell scripts, that are automatically parallelized by the operating sy...

1
голосов
1ответов
650 просмотров

Why does write() to pipe exit program when pipe writes to stdout?

I have a server application that writes to a popen("myCommand", "w") file descriptor in a separate thread and if the command passed to popen() results in any output to stdout or stderr, the my application exits. However, this is only an issue when my server application was invoked via inetd, if ...

15
голосов
2ответов
7544 просмотров

Is there any difference between socketpair and pair of unnamed pipes?

I would like to know not only user-side differences, but differences / common parts in Linux kernel implementation as well.

7
голосов
3ответов
6372 просмотров

How can I use Linux's splice() function to copy a file to another file?

here's another question about splice(). I'm hoping to use it to copy files, and am trying to use two splice calls joined by a pipe like the example on splice's Wikipedia page. I wrote a simple test case which only tries to read the first 32K bytes from one file and write them to another: #define...

3
голосов
4ответов
2935 просмотров

perl hangs on exit (after closing a filehandle)

I've got a function that does (in short): my $file = IO::File->new("| some_command >> /dev/null 2>&1") or die "cannot open some_command for writing: $!\n"; ... undef $file; Right now I'm not even writing anything to $file. Currently there are no other operations on $file a...

25
голосов
4ответов
9913 просмотров

paste without temporary files in Unix

I'm trying to use the Unix command paste, which is like a column-appending form of cat, and came across a puzzle I've never known how to solve in Unix. How can you use the outputs of two different programs as the input for another program (without using temporary files)? Ideally, I'd do this (w...

4
голосов
1ответов
3292 просмотров

Unbuffered CreateNamedPipe for use as stdout for CreateProcess

I would like to execute arbitrary command-line application and read its standard output as it gets produced. I use CreateNamedPipe to create a pipe and then supply other end (open used CreateFile) to CreateProcess. Provided the target process doesn't explicitly manipulates with standard output bu...

1
голосов
3ответов
3548 просмотров

Reading a file name from piped command

So I'm trying to get the C program to read a filename from the command line in the following format: cat (filename path) | (program name) i can get it to read the name of the input file when its entered as a command line argument, but it won't read from the concatenated argument here's the code...

2
голосов
1ответов
1991 просмотров

Using Named Pipes as Files

Simple question here (though perhaps not such a simple answer): Is it possible to specify a path for an (existing) named pipe that can be used by programs as if they were opening on a normal file? According to this MSDN page, name pipes on the local computer can be referrenced using the followi...

7
голосов
4ответов
5830 просмотров

Switch from file contents to STDIN in piped command? (Linux Shell)

I have a program (that I did not write) which is not designed to read in commands from a file. Entering commands on STDIN is pretty tedious, so I'd like to be able to automate it by writing the commands in a file for re-use. Trouble is, if the program hits EOF, it loops infinitely trying to read ...

97
голосов
4ответов
36056 просмотров

Catching error codes in a shell pipe

I currently have a script that does something like ./a | ./b | ./c I want to modify it so that if any of a, b or c exit with an error code I print an error message and stop instead of piping bad output forward. What would be the simplest/cleanest way to do so?

13
голосов
7ответов
5025 просмотров

Force another program's standard output to be unbuffered using Python

A python script is controlling an external application on Linux, passing in input via a pipe to the external applications stdin, and reading output via a pipe from the external applications stdout. The problem is that writes to pipes are buffered by block, and not by line, and therefore delays ...

0
голосов
1ответов
1582 просмотров

Problem with O_NONBLOCK Pipe

I'm trying to send and receive using pipes: send.cpp struct { long a; long b; }T; cout << "1" << endl; if ( access ( FIFO_NAME, F_OK ) == -1 ) { res = mkfifo ( FIFO_NAME, 0755 ); if ( res != 0 ) cout << " Can't make f...

58
голосов
6ответов
43385 просмотров

When should I use GCC's -pipe option?

The GCC 4.1.2 documentation has this to say about the -pipe option: -pipe Use pipes rather than temporary files for communication between the various stages of compilation. This fails to work on some systems where the assembler is unable to read from a pipe; but the GNU assembler has no ...

139
голосов
5ответов
61750 просмотров

With bash, how can I pipe standard error into another process?

It's well known how to pipe the standard ouput of a process into another processes standard input: proc1 | proc2 But what if I want to send the standard error of proc1 to proc2 and leave the standard output going to its current location? You would think bash would have a command along the line...

9
голосов
4ответов
33955 просмотров

Pipe, standard input and command line arguments in Bash

Consider: command1 | command2 Is the output of command1 used as standard input of command2 or as command line arguments to command2? For example, cat test.sh | grep "hehe" What is its equivalent form without using a pipe? I tried grep "hehe" $(cat test.sh) and it seems not to be correct.

16
голосов
9ответов
17083 просмотров

Writing my own shell... stuck on pipes?

For the past few days I have been attempting to write my own shell implementation but I seem to have gotten stuck on getting pipes to work properly. I am able to parse a line and fork off the commands between the pipes (ex: ls | sort) individually but can't seem to get them to pipe input from on...

0
голосов
3ответов
140 просмотров

line of bash code from .configure file

I need to understand the following line of code: BIN_DIR=`grep BIN_DIR= $SMLCM | head -1` where $SMLCH contains a path This is what I understood so far: grep will produce some string(s), possible paths. What does grep do with BIN_DIR=? the pathes are passed to head and all files within the ...

11
голосов
2ответов
3778 просмотров

Python 2.6 send connection object over Queue / Pipe / etc

Given this bug (Python Issue 4892) that gives rise to the following error: >>> import multiprocessing >>> multiprocessing.allow_connection_pickling() >>> q = multiprocessing.Queue() >>> p = multiprocessing.Pipe() >>> q.put(p) >>> q.get() Trac...

12
голосов
4ответов
25534 просмотров

Command Line Pipe Input in Java

Here is a simple piece of code: import java.io.*; public class Read { public static void main(String[] args) { BufferedReader f = new BufferedReader(new InputStreamReader(System.in)); while(true) { String x = null; try{ x = f.readLine(); } catch (IOException e) {e.print...

4
голосов
1ответов
2213 просмотров

Redirecting native dll stdout/stderr from within C#

I'm trying to redirect the output of a third-party native dll which outputs to stdout/stderr from within C#. The output of both stdout and stderr should go to a log file. Here's my idea (x2 for two streams): Create an AnonymousPipeServerStream Get the pipe's handle via _outServer.SafePipeHand...

0
голосов
4ответов
401 просмотров

Sending data between Java to c++ on windows?

I want to send the raw audio buffer to c++ for audio transcoding. I have two option using piped stream using direct buffers (java.nio) Are these really my 2 best options (and which would people recommend?) Thanks!

0
голосов
3ответов
686 просмотров

A doubt on pipes in Unix

This code below is for executing ls -l | wc -l. In the code, if I comment close(p[1]) in parent then the program just hangs, waiting for some input. Why it is so? The child writes output of ls on p1 and parent should have taken that output from p0. #include <stdio.h> #include <stdlib.h&...

1
голосов
2ответов
1617 просмотров

Is there any way to synchronize parent and child in C using one pipe in Unix?

Suppose both parent and child use one pipe for writing and reading means when one writes then only other read otherwise it blocks. Is there any way to do it? I tried to do it with sleep function but due to race conditions, it does not give the correct output. This is my code #include <stdio....

700
голосов
7ответов
476273 просмотров

Redirect Windows cmd stdout and stderr to a single file

I'm trying to redirect all output (stdout + stderr) of a DOS command to a single file: C:12321gt;dir 1> a.txt 2> a.txt The process cannot access the file because it is being used by another process. Is it possible, or should I just redirect to two separate files?

1
голосов
2ответов
910 просмотров

execl pipe without dup

I am trying to execute a program from a parent using execl. I do the normal pipe setup and fork. Here is the trick... I need my children (there can be an arbitrary number of children) to all communicate with the parent. Program "A" (parent) creates pipe forks and execl into "B" (child). In t...

12
голосов
2ответов
9671 просмотров

Bypassing buffering of subprocess output with popen in C or Python

I have a general question about popen (and all related functions), applicable to all operating systems, when I write a python script or some c code and run the resulting executable from the console (win or linux), i can immediately see the output from the process. However, if I run the same execu...

7
голосов
8ответов
41612 просмотров

Using SAS Macro to pipe a list of filenames from a Windows directory

I am trying to amend the macro below to accept a macro parameter as the 'location' argument for a dir command. However I cannot get it to resolve correctly due to the nested quotes issue. Using %str(%') does not work, neither do quoting functions for some reason. The macro will work fine when ...