Created
July 14, 2010 17:17
-
-
Save DTrejo/475693 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getDescription(barcode) { | |
var exec = require('child_process').exec, | |
child, | |
description; | |
// async command line call, takes its time to finish | |
child = exec('curl http://www.upcdatabase.com/item/' + barcode + ' -s | grep Description', | |
function (error, stdout, stderr) { | |
if(stderr.length > 0){ | |
sys.puts('exec stderr: ' + stderr); | |
} | |
if (error !== null) { | |
sys.puts('exec error: ' + error); | |
} | |
description = processPage(stdout); | |
}); | |
return description; // this will return before the above command finishes. | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment