2014-12-22 4 views
0

저는 C++에 컴파일러가 적고 CSS에 몇 가지 기능을 쓰고 있습니다./usr/bin/env : node : 해당 파일 또는 디렉토리가 없습니다. C++

nodejs, less이 설치되어 있습니다. 내가 터미널에서 명령을 실행할 때 내가 덜 파일 test.less

@color: red; 
a{color:@color;} 

을 만들어 :

lessc test.less test.css 

는이 파일에 CSS 만든 이름은 test.css입니다,하지만 난 ++ c를 통해이 명령을 실행할 때, 그것은을 반환 오류. 도와주세요.
std::string shell_exec(std::string cmd) 
{ 
    std::string result = ""; 
    FILE* pipe = popen(cmd.c_str(), "r"); 
    if (pipe == NULL) 
    { 
     return result; 
    } 
    char buffer[128]; 
    while(!feof(pipe)) 
    { 
     if(fgets(buffer, 128, pipe) != NULL) 
     { 
      result += buffer; 
     } 
    } 
    pclose(pipe); 
    return result; 
} 

shell_exec("lessc test.less test.css"); 

가 나는 오류가 발생했습니다 :

/usr/bin/env: node: No such file or directory 

/usr/bin/node가 존재한다이 내 C++ 기능입니다.

enter image description here enter image description here enter image description here

================ UPDATE : 고정 ==================

당신이 궤도에

내가 lessc하는 절대 경로를 추가로 고정에서

shell_exec("/usr/bin/node /usr/bin/lessc test.less test.css"); 
+0

http://stackoverflow.com/a/20890795/560648 –

+0

나는 터미널에서 작동하지만 C++ 프로그램에서는 작동하지 않는다고 정말로 생각하지 않습니다. –

+0

@LightnessRacesinOrbit 사실입니다. –

답변

1

을 nodejs @Lightness 경주 @Bass Jobsen을, 감사합니다 다음 코드를 사용하는 경우 https://stackoverflow.com/a/246/1596547

공지 사항 난 당신의 코드를 컴파일 할 수없는,하지만 난 할 수 있습니다 : https://unix.stackexchange.com/a/29620

The advantage of #!/usr/bin/env python is that it will use whatever python executable appears first in the user's $PATH.

그래서 당신은 당신의 스크립트를 실행하는 사용자의 $PATH에 노드를 추가해야 참조

int main() 
{ 
std::string r = shell_exec("lessc test.less test.css"); 
} 

아마 또한 using namespace stdstring 대신 std:string 사용합니다.

관련 문제