1
我想通過中的system()
函數運行nodejs程序。我可以在終端運行bash命令/usr/local/bin/node ~/some_folder/xml2js.js
,但是當我跑了這一點:Nodejs和UNIX新手:在cpp程序中運行node命令
int main(int argc, const char * argv[])
{
// insert code here...
//system("/usr/local/bin/node ~/some_folder/xml2js.js");
system("~/some_folder/run.sh");
std::cout << "Hello, World!\n";
return 0;
}
它告訴我node: command not found
。 的run.sh低於:
#! /bin/bash
node ./xml2js.js
是否有任何其他的方式來調用UNIX其他程序?以及如何獲得命令的輸出到標準輸出?
我很抱歉,但我忘了告訴'run.sh'是什麼。 – zsf222
您是否嘗試在腳本和'system()'中使用完整路徑? – Alex
另外,如果您不想使用完整路徑,請在腳本中嘗試'node xml2js.js'(不帶./)。 – Alex