popen

subprocess popen to run commands (HDFS/hadoop)

跟風遠走 提交于 2019-12-24 00:40:07
问题 I am trying to use subprocess.popen to run commands on my machine. This is what I have so far cmdvec = ['/usr/bin/hdfs', 'dfs', '-text', '/data/ds_abc/clickstream/{d_20151221-2300}/*', '|', 'wc', '-l'] subproc = subprocess.Popen(cmdvec, stdout=subprocess.PIPE, stdin=None, stderr=subprocess.STDOUT) If I run the command in my terminal I get an output of 15/12/21 16:09:31 INFO lzo.GPLNativeCodeLoader: Loaded native gpl library 15/12/21 16:09:31 INFO lzo.LzoCodec: Successfully loaded &

popen pipe slows down other threads

≯℡__Kan透↙ 提交于 2019-12-24 00:24:46
问题 I have problem with my multithread application. When at one thread executing synchronous popen() command - other application threads are slow down significantly. Thread with popen() execute ffmpeg , that generates high load. Normally, other threads execution time is 0.0007 ms. And when popen is used, some threads are increasing there execution time up to 14-20 seconds. How to solve this problem? System is FreeBSD 6.4 FILE *pipe; char buff[512]; if ( !(pipe = popen( command.c_str(), "r")) ) {

Merge stdout and stderr in Popen

三世轮回 提交于 2019-12-23 21:47:54
问题 In Ruby's popen/spawn, how do I merge both STDOUT and STDERR as a single stream wihthout resorting to using >2&1 ? In Python, this would be: >>> import subprocess >>> subprocess.check_output('my_prog args', stderr=subprocess.STDOUT, shell=True) Note the stderr argument. I use Open3 - as I don't want just stdout - but it already separates them into two streams. 回答1: Using the code from your other question, here you go: cmd = 'a_prog --arg ... --arg2 ...' Open3.popen2({"MYVAR" => "a_value"}, "#

How to open a file in a new process everytime irrespective of fileopener

醉酒当歌 提交于 2019-12-23 18:45:02
问题 I am using windows 7 64 bit python 2.7 I am opening the file, and monitoring the file changes and then waiting till the opened file is closed. This works well in case of simple notepad file opener. As notepad opens each files in a new process ID whereas notepad++ opens different files in a single notepad++ process ID. ACTIONS = { 1 : "Created", 2 : "Deleted", 3 : "Updated", 4 : "Renamed from something", 5 : "Renamed to something" } FILE_LIST_DIRECTORY = 0x0001 class myThread (threading.Thread

use fclose to pipe of popen is a serious bug?

一笑奈何 提交于 2019-12-23 09:07:13
问题 Some months ago I write a CGI application for Linux that uses popen() to read the output of a command, and then I close the pipe with fclose() . Now, I read that for close pipes is needs use pclose() . The manual says: The return value from popen() is a normal standard I/O stream in all respects save that it must be closed with pclose() rather than fclose(3) . My code is like this: if ((NULL != (f = popen(command.value, "r")))) { //do something fclose(f); } My question is: My mistake have a

Unix/Windows, Setup background process? from php code

百般思念 提交于 2019-12-23 03:58:10
问题 So I found a function from http://php.net/manual/en/function.exec.php function execInBackground($cmd) { if (substr(php_uname(), 0, 7) == "Windows"){ pclose(popen("start /B ". $cmd, "r")); } else { exec($cmd . " > /dev/null &"); } } Windows Usage: pclose(popen('start /B php path/to/background_cron.php', 'r')); Unix Usage: exec('php path/to/background_cron.php >> path/to/background_error.log &') But when these lines are called nothing actually happens (after waiting 5 or so minutes). Am I doing

Problem with input filter using doxygen 1.6.3 on windows XP

[亡魂溺海] 提交于 2019-12-23 03:19:05
问题 I am trying to use doxygen to generate documentation for some matlab classes I have written. I am using the doxygen-matlab package, which includes a perl script to kludge matlab .m files into c++ style commented files, so that doxygen can read them. In my doxyfile, I have set (according to the instructions) FILTER_PATTERNS = *m=C:/doxygenMatlab/m2cpp.pl However, when the code runs, rather than running the script on the input files, it appears to just open the script using whatever the default

Python Popen - env - ffmpeg crash

送分小仙女□ 提交于 2019-12-23 02:28:17
问题 I am trying to run an ffmpeg command on Windows 7 (python 2.7) which runs on command line just fine, but the env of my Popen is not working. Here is the working command line: SET FFREPORT=level=48:file=C\:\\temp\\TESTFFMPEGOUTPUT.txt && C:\Temp\ffmpeg\ffmpeg.exe -i “I:\somefolder\testInput.mov" "I:\somefolder\testOutput.mov" And here is my current python code: ffreport = "level=48:file={}".format(self.logFilePath) + " && " startupinfo = subprocess.STARTUPINFO() startupinfo.dwFlags |=

Causes for ENOMEM from ::popen()

僤鯓⒐⒋嵵緔 提交于 2019-12-22 17:40:07
问题 I have an application that mostly works, but am having one condition wherein the call to ::popen() gets an error with errno set to ENOMEM. The man page for ::popen() refers you to page for ::fork() which itself lists ENOMEM with this brief comment on Linux: The fork() function may fail if: ENOMEM Insufficient storage space is available. I am wondering if I am really running out of memory, or perhaps some other resource like file descriptors? Can fork() give ENOMEM for something other than

How to use python Popen with a espeak and aplay

喜夏-厌秋 提交于 2019-12-22 11:14:31
问题 I'm trying to call espeak -ves -s130 'HEY' --stdout | aplay -D 'sysdefault' through subprocess.Popen, with espeak_process = Popen(["espeak", "-ves -s100 'HEY' --stdout"], stdout=subprocess.PIPE) aplay_process = Popen(["aplay", "-D 'sysdefault'"], stdin=espeak_process.stdout, stdout=subprocess.PIPE) But it doesn't work ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM 'sysdefault' aplay: main:682: audio open error: No such file or directory Any idea how to implement this? Thx 回答1: Your