popen

python subprocess Command Line Parsing Error

你。 提交于 2020-01-06 14:41:08
问题 I am running a python program I have coded with a subprocess WolfPsort Program. It is a bioinformatics tool for protein localization detection program. However, the python subprocess does not excute my input file. This is the code #!/usr/bin/python # secref.py is for secretome refining import os import sys import subprocess if len(sys.argv) != 2: print >> sys.stderr, 'Usage: python secref.py [*.fasta]' exit(1) if sys.argv[1].endswith('.fasta'): filename = sys.argv[1] else: print >> sys.stderr

Multiple subprocesses take a lot of time to complete

杀马特。学长 韩版系。学妹 提交于 2020-01-06 08:16:30
问题 I have a single process that is run using subprocess module's Popen : result = subprocess.Popen(['tesseract','mypic.png','myop']) st = time() while result.poll() is None: sleep(0.001) en = time() print('Took :'+str(en-st)) Which results in: Took :0.44703030586242676 Here, a tesseract call is made to process an image mypic.png (attached) and output the OCR's result to myop.txt . Now I want this to happen on multiple processes on behalf of this comment (or see this directly), so the code is

Multiple subprocesses take a lot of time to complete

纵饮孤独 提交于 2020-01-06 08:16:00
问题 I have a single process that is run using subprocess module's Popen : result = subprocess.Popen(['tesseract','mypic.png','myop']) st = time() while result.poll() is None: sleep(0.001) en = time() print('Took :'+str(en-st)) Which results in: Took :0.44703030586242676 Here, a tesseract call is made to process an image mypic.png (attached) and output the OCR's result to myop.txt . Now I want this to happen on multiple processes on behalf of this comment (or see this directly), so the code is

Passing parameters to Python subprocess.Popen

二次信任 提交于 2020-01-06 04:07:05
问题 I'm converting this bash script to Python. I have a working Python version now. However, in order to get it to work, I had to hack the command I passed to subprocess.Popen() by making it into one long string. I do not wish to use one long command string . I wish to break this into the proper individual parameters. How can I do that in this specific example? My specific question is how do I change this line: process = subprocess.Popen(cmd, shell=True, ... into a form like this: process =

Subprocess.CREATE_NEW_CONSOLE

本小妞迷上赌 提交于 2020-01-05 09:13:28
问题 I have this Python code. import subprocess subprocess.Popen("airmon-ng check kill", creationflags = subprocess.CREATE_NEW_CONSOLE) Python 2.7.6 on Linux Mint gives me the following error: subprocess.Popen("airmon-ng check kill", creationflags = subprocess.CREATE_NEW_CONSOLE) AttributeError: 'module' object has no attribute 'CREATE_NEW_CONSOLE' The same on Windows 8.1 gives me this: Traceback (most recent call last): File "C:\Users\Ben\Dropbox\Coding\jam.py", line 10, in <module> subprocess

Subprocess.CREATE_NEW_CONSOLE

懵懂的女人 提交于 2020-01-05 09:13:28
问题 I have this Python code. import subprocess subprocess.Popen("airmon-ng check kill", creationflags = subprocess.CREATE_NEW_CONSOLE) Python 2.7.6 on Linux Mint gives me the following error: subprocess.Popen("airmon-ng check kill", creationflags = subprocess.CREATE_NEW_CONSOLE) AttributeError: 'module' object has no attribute 'CREATE_NEW_CONSOLE' The same on Windows 8.1 gives me this: Traceback (most recent call last): File "C:\Users\Ben\Dropbox\Coding\jam.py", line 10, in <module> subprocess

use generator as subprocess input; got “I/O operation on closed file” exception

。_饼干妹妹 提交于 2020-01-05 02:52:27
问题 I have a large file that needs to be processed before feeding to another command. I could save the processed data as a temporary file but would like to avoid it. I wrote a generator that processes each line at a time then following script to feed to the external command as input. however I got "I/O operation on closed file" exception at the second round of the loop: cmd = ['intersectBed', '-a', 'stdin', '-b', bedfile] p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE,

Why does _popen work here, but boost::process does not?

浪子不回头ぞ 提交于 2020-01-04 13:29:39
问题 I have the following working code using _popen, on windows, m_pGNUPlot = _popen("/gnuplot/bin/gnuplot.exe", "w"); fprintf(m_pGNUPlot, "set term win\n"); fprintf(m_pGNUPlot, "set term pngcairo\n"); fprintf(m_pGNUPlot, "plot \"\Data.txt\" using 1:2 notitle\n"); fprintf(m_pGNUPlot, "set output \"\Out.png\"\n"); fprintf(m_pGNUPlot, "replot\n"); fflush(m_pGNUPlot); But the problem with this is that cmd window keeps poping up, and there is no way to prevent that (Link) So, I write the equivalent

Why does _popen work here, but boost::process does not?

筅森魡賤 提交于 2020-01-04 13:26:24
问题 I have the following working code using _popen, on windows, m_pGNUPlot = _popen("/gnuplot/bin/gnuplot.exe", "w"); fprintf(m_pGNUPlot, "set term win\n"); fprintf(m_pGNUPlot, "set term pngcairo\n"); fprintf(m_pGNUPlot, "plot \"\Data.txt\" using 1:2 notitle\n"); fprintf(m_pGNUPlot, "set output \"\Out.png\"\n"); fprintf(m_pGNUPlot, "replot\n"); fflush(m_pGNUPlot); But the problem with this is that cmd window keeps poping up, and there is no way to prevent that (Link) So, I write the equivalent

Python: Execute scp, stdin for password not working

☆樱花仙子☆ 提交于 2020-01-03 03:34:14
问题 I'm trying the following from subprocess import Popen, PIPE Popen(["scp", "-B","user@url:file", "."], stdin=PIPE, shell=False).communicate(input="password") But I still get the password promt, and no password is sent. I know I can use scp with keys, but this is not what I need. Any help? 回答1: scp interacts with the terminal directly, rather than reading from STDIN , You can't pass the password via a pipe, it security matter for scp and it's the same for sftp, ssh. you can try it in you