0

Hi I would like to run this script with bash command. I already installed node

How can I run this? Also I would like to parse some variable example node bb.js NiceTitle ./file.txt

<script type="text/javascript" src="http://binbox.io/api.js"></script>
<script type="text/javascript">
    var BB = new Binbox.API("http://api.binbox.io/");
    BB.create({
        title: "here the NiceTitle from command",
        text: "Here a path to ./file.txt",
    }, function(result)
    {
        console.log(result);

        if(result.ok)
        {
            console.log(result.id, result.salt);
        }
        else
        {
            console.log(result.error);
        }
    });
</script>
1
  • Create a node module and then run it with node <modulename>. Commented Nov 2, 2014 at 21:52

1 Answer 1

2

Make js file with

var BB = new Binbox.API("http://api.binbox.io/");
BB.create({
    title: "here the NiceTitle from command",
    text: "Here a path to ./file.txt",
}, function(result)
{
    console.log(result);

    if(result.ok)
    {
        console.log(result.id, result.salt);
    }
    else
    {
        console.log(result.error);
    }
});

content (for example file.js), then you can run with

node file.js

or from bash

P.S. Sure you will need require in the top to include lib

P.P.S. For arguments parsing there is process.argv http://nodejs.org/docs/latest/api/process.html#process_process_argv

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.