external-process

Java external program

ぐ巨炮叔叔 提交于 2019-11-28 10:34:09
问题 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? 回答1: 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:/

Invoke external shell script from PHP and get its process ID

拟墨画扇 提交于 2019-11-28 08:10:17
How can I invoke an external shell script (Or alternatively an external PHP script) from PHP itself and get its process ID within the same script? $command = 'yourcommand' . ' > /dev/null 2>&1 & echo $!; '; $pid = exec($command, $output); var_dump($pid); Mark Amery If you want to do this strictly using tools PHP gives you, rather than Unix-specific wizardry , you can do so with proc_open and proc_get_status , although the need to pass a descriptor spec into proc_open makes it unpleasantly verbose to use: <?php $descriptorspec = [ 0 => ['pipe', 'r'], 1 => ['pipe', 'w'], 2 => ['pipe', 'w'] ];

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

a 夏天 提交于 2019-11-28 07:13:25
问题 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

How do I find out if a process is already running using c#?

谁都会走 提交于 2019-11-28 04:23:31
I have C# winforms application that needs to start an external exe from time to time, but I do not wish to start another process if one is already running, but rather switch to it. So how in C# would I so this in the example below? using System.Diagnostics; ... Process foo = new Process(); foo.StartInfo.FileName = @"C:\bar\foo.exe"; foo.StartInfo.Arguments = "Username Password"; bool isRunning = //TODO: Check to see if process foo.exe is already running if (isRunning) { //TODO: Switch to foo.exe process } else { foo.Start(); } This should do it for ya. Check Processes //Namespaces we need to

Calling external program from R with multiple commands in system

牧云@^-^@ 提交于 2019-11-28 01:07:49
问题 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

How to launch and run external script in background? [duplicate]

淺唱寂寞╮ 提交于 2019-11-27 20:59:42
问题 This question already has answers here : How to start a background process in Python? (7 answers) Closed 6 years ago . I tried these two methods: os.system("python test.py") subprocess.Popen("python test.py", shell=True) Both approaches need to wait until test.py finishes which blocks main process. I know "nohup" can do the job. Is there a Python way to launch test.py or any other shell scripts and leave it running in background? Suppose test.py is like this: for i in range(0, 1000000): print

Invoke external shell script from PHP and get its process ID

隐身守侯 提交于 2019-11-27 02:06:43
问题 How can I invoke an external shell script (Or alternatively an external PHP script) from PHP itself and get its process ID within the same script? 回答1: $command = 'yourcommand' . ' > /dev/null 2>&1 & echo $!; '; $pid = exec($command, $output); var_dump($pid); 回答2: If you want to do this strictly using tools PHP gives you, rather than Unix-specific wizardry, you can do so with proc_open and proc_get_status, although the need to pass a descriptor spec into proc_open makes it unpleasantly

How do I find out if a process is already running using c#?

半世苍凉 提交于 2019-11-27 00:22:53
问题 I have C# winforms application that needs to start an external exe from time to time, but I do not wish to start another process if one is already running, but rather switch to it. So how in C# would I so this in the example below? using System.Diagnostics; ... Process foo = new Process(); foo.StartInfo.FileName = @"C:\bar\foo.exe"; foo.StartInfo.Arguments = "Username Password"; bool isRunning = //TODO: Check to see if process foo.exe is already running if (isRunning) { //TODO: Switch to foo

How to call an external program in python and retrieve the output and return code?

女生的网名这么多〃 提交于 2019-11-26 18:47:22
How can I call an external program with a python script and retrieve the output and return code? jkp Look at the subprocess module: a simple example follows... from subprocess import Popen, PIPE process = Popen(["ls", "-la", "."], stdout=PIPE) (output, err) = process.communicate() exit_code = process.wait() Following Ambroz Bizjak's previous comment, here is a solution that worked for me: import shlex from subprocess import Popen, PIPE cmd = "..." process = Popen(shlex.split(cmd), stdout=PIPE) process.communicate() exit_code = process.wait() Check out the subprocess module here: http://docs

C# : Redirect console application output : How to flush the output?

空扰寡人 提交于 2019-11-26 11:33:00
问题 I am spawning external console application and use async output redirect. as shown in this SO post My problem is it seems that the spawned process needs to produce certain amount of output before I get the OutputDataReceived event notification. I want to receive the OutputDataReceived event as soon as possible. I have a bare-bones redirecting application, and here are some observations: 1. When I call a simple \'while(true) print(\"X\");\' console application (C#) I receive output event