child-process

Using two commands (using pipe |) with spawn

余生长醉 提交于 2019-12-07 13:05:06
问题 I'm converting a doc to a pdf (unoconv) in memory and printing (pdftotext) in the terminal with: unoconv -f pdf --stdout sample.doc | pdftotext -layout -enc UTF-8 - out.txt Is working. Now i want use this command with child_process.spawn : let filePath = "...", process = child_process.spawn("unoconv", [ "-f", "pdf", "--stdout", filePath, "|", "pdftotext", "-layout", "-enc", "UTF-8", "-", "-" ]); In this case, only the first command (before the |) is working. Is i possible to do what i'm

How to pass an input and retrieve an output to a child process in C language

你离开我真会死。 提交于 2019-12-07 12:25:28
问题 I have an exe program in Windows which in the terminal works as follows > program.exe parameter01 file entry01 (user types entry01) output01 entry02 (user types entry02) output02 ... until the combination Ctrl+D is pressed. I need to create a "child process" in a C language which is capable to run the program and sent entries to the "child process" and receive the output in a char[] or string. I know I have to use the CreateProcess method but I don't know how to pass an entry like an input

Do I have to close inherited handle later owned by child process?

*爱你&永不变心* 提交于 2019-12-07 01:00:58
问题 Microsoft played safe here. In their article, "Creating a Child Process with Redirected Input and Output", they are saying: The remaining open handles are cleaned up when this process terminates. To avoid resource leaks in a larger application, close handles explicitly. Which is perfectly useless. What handles? In which process? I want to get my head around it. When a handle is created in parent process with SECURITY_ATTRIBUTES.bInheritHandle = TRUE , a child process can see and use it, and

Node.js: Object value as stdout of child_process.exec

心已入冬 提交于 2019-12-06 15:00:59
I'm new to Node and stumbling on some of the nonblocking elements of it. I'm trying to create a object and have one of the elements of it being a function that returns the stdout of a child_process.exec, like so: var exec = require('child_process').exec; var myObj = {}; myObj.list = function(){ var result; exec("ls -al", function (error, stdout, stderr) { result = stdout; }); return result; } console.log('Ta da : '+myObj.list); I figure that myObj.list is returning result before it is set as stdout , but I can't figure out how to make it wait or do a callback for it. Thanks for your help! You

Using two commands (using pipe |) with spawn

偶尔善良 提交于 2019-12-06 03:54:22
I'm converting a doc to a pdf (unoconv) in memory and printing (pdftotext) in the terminal with: unoconv -f pdf --stdout sample.doc | pdftotext -layout -enc UTF-8 - out.txt Is working. Now i want use this command with child_process.spawn : let filePath = "...", process = child_process.spawn("unoconv", [ "-f", "pdf", "--stdout", filePath, "|", "pdftotext", "-layout", "-enc", "UTF-8", "-", "-" ]); In this case, only the first command (before the |) is working. Is i possible to do what i'm trying? Thanks. UPDATE- Result of: sh -c- .... bash-3.2$ sh -c- unoconv -f pdf --stdout /Users/fatimaalves

Passing 2 stdin arguments to a ImageMagick child_process

ぐ巨炮叔叔 提交于 2019-12-06 03:19:55
I have certain limitations that I won't specify that require me to use ImageMagick as a child-process. I have multiple base 64 strings of jpg files which I want ImageMagick to process. Specifically I want ImageMagick to join the jpg files together. If I had 2 regular jpg files then from the command line I would use the following format. node convert in_1.jpg in_2.jpg +append out.jpg in a js file I would use var spawn, magicCommands, imagic; spawn = require('child_process').spawn; magicCommands = ["in_1.jpg", "in_2.jpg", "+append", "out.jpg"]; imagic = spawn("convert", magicCommands); Now if I

How do I convert an h.264 stream to MP4 using ffmpeg and pipe the result to the client?

依然范特西╮ 提交于 2019-12-05 19:04:13
I have an h.264 encoded stream of video on my server (node.js) and I want to use ffmpeg to convert it to an MP4 stream. Then I want to pipe that MP4 stream from the child process to the client using the response of an HTTP server that I have set up. I am very confused about all the options ffmpeg has and not sure how to pipe the output of the child process to the HTTP response. I have tried several combinations of ffmpeg options but the video does not play in the browser (or show any sign of receiving data) and I don't know if I am converting it to MP4 corretly. I am also not sure I am piping

How can I make Perl wait for child processes started in the background with system()?

一笑奈何 提交于 2019-12-05 18:10:24
问题 I have some Perl code that executes a shell script for multiple parameters, to simplify, I'll just assume that I have code that looks like this: for $p (@a){ system("/path/to/file.sh $p&"); } I'd like to do some more things after that, but I can't find a way to wait for all the child processes to finish before continuing. Converting the code to use fork() would be difficult. Isn't there an easier way? 回答1: Using fork/exec/wait isn't so bad: my @a = (1, 2, 3); for my $p (@a) { my $pid = fork()

Why can't Dart's “Process.start” execute an Ubuntu command when the command works in Ubuntu terminal?

折月煮酒 提交于 2019-12-05 17:45:46
I have command I would like to call with Dart. The command is sonar-runner which works perfectly if I run it in a normal Ubuntu terminal. This is because I have edited the PATH in the .profile file so it becomes a global command. However, if I wrote a simple Process.start code that should trigger the same thing: Process.run('sonar-runner', []).then((result) { stdout.write(result.stdout); stderr.write(result.stderr); }); I get as a response: Uncaught Error: ProcessException: No such file or directory Command: sonar-runner Unhandled exception: ProcessException: No such file or directory Command:

Running a node.js script every 10 seconds

浪尽此生 提交于 2019-12-05 17:18:54
I just started using Node.js and I'm now trying to make my script run in the background every 10 seconds like a daemon waiting for something to do, when there is something to run from the database It reads the output from the program and does certain tasks depending on the output. This is what I've been able to do so far, It works just as I intended but can only run once even in the background. How can I make it run like a daemon every 10 seconds? Code: var spawn = require('child_process').spawn; var mysql = require('mysql'); var JSFtp = require('jsftp'); var check = require('node-validator')