Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

if (stdout=="E") always return false

if (stdout=="E") always return false


I m comparing the output of childprocess.exec to a tring, but I must overlook something since I don t get the expected result.

function download_all(list, callback){
    var i=0, cmd="";

    function afterDownload(){...}


Basically, I check if a file Exist, look at the output of the command, and if it is not E (wich sign the file exist), download it. The problem is, even when the file exist, the app try to download LINK+E, wich doesn t exist and of course fail.

I ve tried with === instead of ==, and " instead of ', but it didn t changed anything.

Is there some character in stdout other than E?

Problem courtesy of: DrakaSAN


NodeJS has the "fs" module which takes care of that for you. The documentation is at

You can do this:

fs.exists(list[i], function (exists) {
  console.log("exists = ", exists);
Solution courtesy of: randunel


View additional discussion.

This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

if (stdout=="E") always return false


Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription