0

I want to catch the time when this "done" is outputted in the console, but I am not sure how to do this:

var cp = require('child_process');

cp.exec('avconv -strict experimental -i ' + filename + ' ' + tempname + ';' + ' echo done', function(err, stdout, stderr) {
    console.log(err);
    console.log(stdout);
    console.log(stderr);
});

Tried checking the stdout, but it just brings lots of information about the file.

avconv is a tool for converting files so my goal in here is to check when the converting is done and proceed further on.

2 Answers 2

1

stdout does return the output from the command. You should try something simpler at first to see if you're actually calling the command correctly.

Try this:

child_process.exec('ls', function (err, stdout, stderr){
    if (err) {
        console.log("error: " + err.code);
    }
    console.log(stdout);
});
Sign up to request clarification or add additional context in comments.

4 Comments

This works, it brings back the content of the server folder. There fore my version - cp.exec('avconv -strict experimental -i ' + filename + ' ' + tempname + ';' + ' echo done', function(err, stdout, stderr) also works, therefore I am not sure if it outputs when done or in the process of converting the file.
Why do you need to output 'done' after the code is done? You'll know when avconv finishes because you get the callback.
I guess, this is what I needed! Thanks!
0

You can get the time when exec's callback will called

var cp = require('child_process');
cp.exec('ls', function(err, stdout, stderr) {
   console.log(new Date())
});

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.