pipe

How can I get the output of a Python subprocess command that contains a pipe?

淺唱寂寞╮ 提交于 2020-01-20 08:55:03
问题 I have: cmd_array = ['head', '-n', str(source_noise_end), "data/noise/" + source + '_16k.dat', '|', 'tail', '-' + str(source_noise_start)] source_noise = subprocess.check_output(cmd_array) The command is valid when I type it into Linux. I get subprocess.CalledProcessError: Command '['head', '-n', '2366468', 'data/noise/white_16k.dat', '|', 'tail', '-2183988']' returned non-zero exit status 1. What am I doing wrong? 回答1: Try with this : import subprocess # cmd contains shell command cmd="your

Bash piping output and input of a program

纵然是瞬间 提交于 2020-01-17 04:56:09
问题 I'm running a minecraft server on my linux box in a detached screen session. I'm not very fond of screen very much and would like to be able to constantly pipe the output of the server to a file(like a pipe) and pipe some input from a file to the server(so that I can input and output to the server from remote programs, like a python script). I'm not very experienced in bash, so could somebody tell me how to do this? Thanks, NikitaUtiu. 回答1: It's not clear if you need screen at all. I don't

Popen mixed data stream?

。_饼干妹妹 提交于 2020-01-16 19:37:06
问题 I've got problem with Popen and Pipes on Windows. I think Popen mixed data between stdout and stderr. When my program reads only stdout everything is OK but when I read stdout and stderr some data from stdout is thrown to stderr. My read method: for line in iter(self._read_obj.readline, b''): self._queue.put(line) sleep(.2) Where self._read_obj is either stderr or stdout. Do you know how can I solve this? 回答1: from subproccess import * x = Popen('sh /root/script.sh', stdout=PIPE, stderr=PIPE,

Signal handler not working on process opened via pipe

你离开我真会死。 提交于 2020-01-16 08:16:29
问题 Note: this is a general question (not limited to wolfram command, and you don't have to know about wolfram ). I consider wrapping wolfram (CUI calculator like python interpreter). Without any wrapper, SIGINT causes the program to suspend the calculation. $ /usr/bin/wolfram -noinit In[1] := While[True, 1] #start infinite loop #execute `kill -SIGINT` from another shell to send SIGINT Interrupt> #calculation now interrupted (you can cancel or resume it) However, with a wrapper, SIGINT causes

Library for Dataflow in C

大兔子大兔子 提交于 2020-01-16 06:06:11
问题 How can I do dataflow (pipes and filters, stream processing, flow based) in C? And not with UNIX pipes. I recently came across stream.py. Streams are iterables with a pipelining mechanism to enable data-flow programming and easy parallelization. The idea is to take the output of a function that turns an iterable into another iterable and plug that as the input of another such function. While you can already do this using function composition, this package provides an elegant notation for it

Library for Dataflow in C

耗尽温柔 提交于 2020-01-16 06:06:04
问题 How can I do dataflow (pipes and filters, stream processing, flow based) in C? And not with UNIX pipes. I recently came across stream.py. Streams are iterables with a pipelining mechanism to enable data-flow programming and easy parallelization. The idea is to take the output of a function that turns an iterable into another iterable and plug that as the input of another such function. While you can already do this using function composition, this package provides an elegant notation for it

Why is my piping failing?

亡梦爱人 提交于 2020-01-16 02:12:10
问题 I've been messing around with .cmd scripts, and wanted to practice piping. I wrote one script to make files, and another to edit them with Notepad++. The making script (called create.cmd) is as follows: @echo off copy nul %1 > nul echo %1 And the edit script (called edit.cmd) is as follows: @echo off start notepad++.exe %1 Now, I wanted to try and make a file, and then pipe its output (hence the echo line) in the form of the name of the file to the edit script. So what I wrote was this:

Piping ppm image to eog image viewer not working

百般思念 提交于 2020-01-16 00:53:12
问题 I am working on an image processing project in C++. To display the images I want to use the default ubuntu image viewer (eog). I have functions in my Image16 class which can read and write PPM files. I know these work because I can write them to the hard disk and then open them with eog. However I do not want to be writing the images to my hard disk because I have an SSD and each image is about 100 Mb. I want to directly pipe the image data into eog. This however is generating an error and I

select.select issue for sockets and pipes

拥有回忆 提交于 2020-01-15 18:36:42
问题 I am currently in the process of writing a basic python script that makes use of both pipes and sockets. The pipe currently holds incoming data from an html form, the socket makes up a connection to a server that sends TCP/IP commands at various intervals. The form and server are on the same LAN but different computers. The code I have is as follows: #!/usr/bin/env python import os,sys,time from socket import * HOST = 'xxx.xxx.xxx.xxx' PORT = 6000 BUFSIZ = 1024 ADDR = (HOST, PORT) tcpCliSock

select.select issue for sockets and pipes

徘徊边缘 提交于 2020-01-15 18:33:30
问题 I am currently in the process of writing a basic python script that makes use of both pipes and sockets. The pipe currently holds incoming data from an html form, the socket makes up a connection to a server that sends TCP/IP commands at various intervals. The form and server are on the same LAN but different computers. The code I have is as follows: #!/usr/bin/env python import os,sys,time from socket import * HOST = 'xxx.xxx.xxx.xxx' PORT = 6000 BUFSIZ = 1024 ADDR = (HOST, PORT) tcpCliSock