Skip to content

Instantly share code, notes, and snippets.

@DTrejo
Created July 14, 2010 17:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DTrejo/475693 to your computer and use it in GitHub Desktop.
Save DTrejo/475693 to your computer and use it in GitHub Desktop.
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