簡體   English   中英

從bash運行API javascript

[英]Running API javascript from bash

嗨,我想使用bash命令運行此腳本。 我已經安裝了節點

我該如何運行? 我也想解析一些變量示例節點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>

使js文件

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);
    }
});

內容(例如file.js),則可以使用

node file.js

或從bash

PS當然,您需要在頂部包含lib的要求

PPS對於參數解析,有process.argv http://nodejs.org/docs/latest/api/process.html#process_process_argv

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM