external-process

python: run a process with timeout and capture stdout, stderr and exit status [duplicate]

微笑、不失礼 提交于 2019-12-03 00:23:47
Possible Duplicate: subprocess with timeout What is the easiest way to do the following in Python: Run an external process Capture stdout in a string, stderr, and exit status Set a timeout. I would like something like this: import proc try: status, stdout, stderr = proc.run(["ls", "-l"], timeout=10) except proc.Timeout: print "failed" I hate doing the work by myself. Just copy this into your proc.py module. import subprocess import time import sys class Timeout(Exception): pass def run(command, timeout=10): proc = subprocess.Popen(command, bufsize=0, stdout=subprocess.PIPE, stderr=subprocess

Starting from Excel (VBA): Launch an external interactive program, and in there launch commands and read their output : is this possible?

泄露秘密 提交于 2019-12-02 07:28:07
Currently I'm doing the following for analysing a memory leak: I open both dumps, using Windbg. I launch heap_stat script, a Python-based script for making a summary of the objects, used in the heap. I copy the results of both heap_stat scripts, and paste them in an Excel sheet, where the results are analysed. I'd like to automate this, starting from the final Excel sheet, using VBA, as follows: Start two instances of an external program ( Windbg.exe ) and open both dumps with them. In those Windbg instances, launch the necessary commands ( .load pykd.pykd , followed by .py heap_stat.py -stat

Interrupt an external method call in java Thread

血红的双手。 提交于 2019-12-01 15:02:42
My java program use an external method(i dont have the source code) that takes a while to finish so i have made the call to that method in a Thread class (in its run method). Now the problem is how do I stop the Thread instantly (not wait for the method to end) if user wants to exit program. When I call my Thread's interrupt method nothing happens, no interrupted exception before the external method is finished. I thought an interrupted exception could occur and be caught at the same time that the external method is running but maybe not? I'm not sure how about how Threads works exactly. So

Interrupt an external method call in java Thread

僤鯓⒐⒋嵵緔 提交于 2019-12-01 12:37:40
问题 My java program use an external method(i dont have the source code) that takes a while to finish so i have made the call to that method in a Thread class (in its run method). Now the problem is how do I stop the Thread instantly (not wait for the method to end) if user wants to exit program. When I call my Thread's interrupt method nothing happens, no interrupted exception before the external method is finished. I thought an interrupted exception could occur and be caught at the same time

Why doesn't VS2010 debugger stop at my breakpoints?

可紊 提交于 2019-11-30 18:18:21
I am working on a C#.NET class library project in VS2010. In my project settings -> debug settings, I have the project set to start an external program (C:\Windows\SysWOW64\wscript.exe) which runs a very simple jscript file (test.js). The script simply creates an instance of the class and calls one of it's methods. The problem is when I start debugging, VS2010 does not stop at any of my breakpoints. If I open up the exact same project in VS2008 it does stop at the break points. Is there a new setting somewhere that is preventing the breakpoints from being hit? Has anyone else ran into this

Why doesn't VS2010 debugger stop at my breakpoints?

风流意气都作罢 提交于 2019-11-30 02:20:11
问题 I am working on a C#.NET class library project in VS2010. In my project settings -> debug settings, I have the project set to start an external program (C:\Windows\SysWOW64\wscript.exe) which runs a very simple jscript file (test.js). The script simply creates an instance of the class and calls one of it's methods. The problem is when I start debugging, VS2010 does not stop at any of my breakpoints. If I open up the exact same project in VS2008 it does stop at the break points. Is there a new

Java external program

点点圈 提交于 2019-11-29 16:31:46
I'd like to start external third party application from my Java application. This external application should run all the time whilst my java application runs. From time to time (it depends on user interaction) my java app should be able to read and write to this external application via stdin and stdout . How can I do that? Is ex-app native code, or another Java program? If it's native code, look at http://download.oracle.com/javase/1.5.0/docs/api/java/lang/Process.html and http://download.oracle.com/javase/1.5.0/docs/api/java/lang/Runtime.html Those will allow you to execute a native program

How to execute a .bat file from a C# windows form app?

主宰稳场 提交于 2019-11-29 13:16:38
What I need to do is have a C# 2005 GUI app call a .bat and several VBScript files at user's request. This is just a stop-gap solution until the end of the holidays and I can write it all in C#. I can get the VBScript files to execute with no problem but I am unable to execute the .bat file. When I "click" in the C# app to execute the .bat file a DOS window opens up and closes very fast and the test .bat file does not execute - "Windows does not recognize bat as an internal or external command" is the error returned in the DOS box. If I simply doubl-click the .bat file or manually run it from

Calling external program from R with multiple commands in system

爱⌒轻易说出口 提交于 2019-11-29 07:27:52
I am new to programming and mainly I am able to do some scripts within R, but for my work I need to call an external program. For this program to work on the ubuntu's terminal I have to first use setenv and then execute the program. Googling I've found the system () and Sys.setenv() functions, but unfortunately I can make it function. This is the code that does work in the ubuntu terminal: $ export PATH=/home/meme/bin:$PATH $ mast "/home/meme/meme.txt" "/home/meme/seqs.txt" -o "/home/meme/output" -comp Where the first two arguments are input files, the -o argument is the output directory and

Nodejs Child Process: write to stdin from an already initialised process

こ雲淡風輕ζ 提交于 2019-11-28 17:46:07
I am trying to spawn an external process phantomjs using node's child_process and then send information to that process after it was initialized, is that possible? I have the following code: var spawn = require('child_process').spawn, child = spawn('phantomjs'); child.stdin.setEncoding = 'utf-8'; child.stdout.pipe(process.stdout); child.stdin.write("console.log('Hello from PhantomJS')"); But the only thing I got on the stdout is the initial prompt for phantomjs console. phantomjs> So it seems the child.stdin.write is not making any effect. I am not sure I can send additional information to