我有一个shell脚本:
/**
* this will convert the whole json into map which you can use to determine the json elements
*
* @param json
*/
private void getModelFromJson(JsonObject json) {
Gson gson = new Gson();
Map<String, JsonElement> jsonElementMap = gson.fromJson(json.toString(), new TypeToken<Map<String, JsonElement>>() {
}.getType());
for (Map.Entry<String, JsonElement> jsonElementEntry : jsonElementMap.entrySet()) {
if (jsonElementEntry.getValue().isJsonPrimitive()) {
//json primitives are data types, do something
//get json boolean
//you can here also check if json element has some json object or json array or primitives based on that
//you can convert this to something else after comparison
if (true) {
InterestModelResponse response = gson.fromJson(jsonElementEntry.getValue().getAsJsonObject().toString(), InterestModelResponse.class);
//use your dynamic converted model
}
} else {
//do something else
}
}
}
当我在hpc(qsub)上运行脚本时,它会返回错误日志:
#!/bin/bash
source activate nanopore_py3
REF=/mnt/projects/lich/stooldrug/iRep_temp/co_growth/MG1655.fasta
iRep -f $REF -s MMF064_HS006/MMF064_2.sam -o MMF064.iRep
奇怪的是,当我在终端上运行/opt/p6444/n121/job_scripts/19745189: line 3: activate: No such file or directory
/opt/p6444/n121/job_scripts/19745189: line 7: iRep: command not found
时,一切正常。我还在$ PATH中添加了source命令的路径。
有人可以帮忙吗?
答案 0 :(得分:0)
您的脚本在其自己的外壳环境中运行,因此不了解您环境中的PATH
变量。您需要在脚本中设置PATH
,并包括要执行的程序的位置。
#!/bin/bash
export PATH=$PATH:/some/path/bin
source activate nanopore_py3
# ...
或者,您可以source
完整路径:
source /some/path/activate /other/path/nanopore_py3