2017-10-12 2 views
0

메이크 스크립트 실행 :'그런 파일이 없습니다 또는 디렉토리'폴더 구조가과 같이 설정

do_stuff: 
    for ks in keyspaces/*; do \ 
     cqlsh -f "$${ks}/bootstrap.cql"; \ 
    done 

:이 코드를 포함하는 I 메인 디렉토리에 Makefile을 가지고

Main directory 
    \_ keyspaces 
    \_ f1 
     \_ bootstrap.cql 
     \_ anotherFolder 
     \_ 0001-something.cql 
    \_ f2 
     \_ bootstrap.cql 
     \_ anotherFolder 
     \_ 0001-something.cql 
     \_ 0002-moreSomething.cql 

에게 make do_stuff을 메인 디렉토리에서 (iTerm2를 사용하여) 터미널에서 실행하면 다음과 같은 오류 메시지가 나타납니다.

Can't open 'keyspaces/f1/bootstrap.cql': [Errno 2] No such file or directory: 'keyspaces/f1/bootstrap.cql' 
command terminated with exit code 1 
Can't open 'keyspaces/f2/bootstrap.cql': [Errno 2] No such file or directory: 'keyspaces/f2/bootstrap.cql' 
command terminated with exit code 1 
make: *** [do_stuff] Error 1 

그러나 터미널에서 이것을 실행하면 : cat keyspaces/f1/bootstrap.sql 그 파일의 내용이 출력되므로 경로가 정확하고 존재하지만 cqlsh는 인식 할 수 없습니까?

the Cassandra/cqlsh docs에서 보면 -f 명령을 올바르게 사용하고있는 것처럼 보이므로 오류가 발생하는 이유를 알 수 없습니다. 내가 Makefile을 다음과 같은 잠재적 인 문제

. 
├── Makefile 
└── keyspaces 
    ├── f1 
    │   └── bootstrap.cql 
    └── f2 
     └── bootstrap.cql 

을 제거하는 간단한 단계를 시작할 것

+0

'cat keyspaces/f1/bootstrap.cql'은 어떻습니까? – Beta

답변

1

는, 그 Main directory 안에는 수,

do_stuff: 
    for ks in keyspaces/*; do \ 
     cat "$${ks}/bootstrap.cql"; \ 
    done 

실행

make 
for ks in keyspaces/*; do \ 
     cat "${ks}/bootstrap.cql"; \ 
    done 
a 
b 

더블 체크 잘 작동

으로 전화
cqlsh -f "keyspaces/f1/bootstrap.cql" 

아마도 이것을 find에 위임 할 수 있습니까?

do_stuff: 
    find `pwd` -name "*.cql" -exec cat {} \; 
+0

'cat'을 사용한 첫 번째 루프는 정상적으로 작동하지만'주 디렉토리 '에서 실행하도록 제안한 마지막 코드 줄은 발견되지 않은 오류를 던집니다. 그래서 카산드라 명령에 잘못된 것이 있어야합니다. 실행 :/알아낼 경우 업데이트를 게시합니다. 감사! – Attila

+0

질문이 하나 더 있습니다. 메이크 파일 대신 find를 사용하면 될까요? 'pwd' -name "* .cql"-exec cqlsh -f {} \를 찾으십시오; – mko

+0

작동하는 것처럼 보이지만 루프에서 사용할 때'find : -exec : no terminating ";" 또는 "+"' – Attila

관련 문제