将标志传递给bash脚本

时间:2016-03-24 01:52:21

标签: bash command-line-arguments

我有以下脚本来调用node.js脚本:

declare -a years=(
  '2011'
  '2012'
  '2013'
  '2014'
  '2015'
  '2016'
)

  for year in "${years[@]}"
  do
    gps --type=CNPJ --format=XLS --identification=??? --password=???? --competence=${year} --output="THE Identification - $year"
  done

我想打个电话:

bash gps.sh --identification=1234567890 --password=123456

有可能吗?目前我需要每次更改文件并进行调用,并且作为标志传递我会更快。

感谢。

1 个答案:

答案 0 :(得分:3)

替换

function sendPut2() {
    var http = new XMLHttpRequest();
    var url = 'http://localhost:8080/answer';
    var data = JSON.stringify({"question": "a", "answer": "b"});
    http.open("PUT", url, true);
    http.setRequestHeader("Content-type", "application/json");
    http.setRequestHeader("Content-Length", data.length);
    http.setRequestHeader("Connection", "close");
    http.onreadystatechange = function() { 
        if(http.readyState == 4 && http.status == 200) {
            alert(http.responseText);
        }
    }
    http.send(data);
}

通过

--identification=??? --password=????