简体   繁体   中英

Decoding mongodump's stderr

I'm trying to mongodump my DB from my Node.js code:

var args = ['--db', 'DBName', '--out', backupDirectory];
        var mongodump = spawn('/usr/local/bin/mongodump', args);

        mongodump.stdout.on('data', function (data) {
           console.log(data);
        });
        mongodump.stderr.on('data', function (data) {
            console.log(data);
        });
        mongodump.on('exit', function (code: number) {
            console.log('mongodump exited with code ' + code);
        });

mongodump.stderr is reached. There, I get a byte array containing 155 bytes.

How can I decode the byte array into a readable message? What's the format that the stderr is encoded to?

Both the DB and my app run on the same machine whose OS is Ubuntu 14.

您可以尝试使用data.toString()。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM