2017-10-12 372 views
0

的文件夹结构设置,像这样的时候:“没有这样的文件或目录”运行的Makefile脚本

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

我有一个Makefile在主目录中包含该代码:

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

当我在我的终端(使用iTerm2)在主目录内运行make do_stuff时,出现以下错误消息:

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命令,所以我不知道为什么我会得到错误。

+0

'cat keyspaces/f1/bootstrap.cql'? – Beta

回答

1

我会用简单的步骤,开始以消除潜在的问题

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

与下面的Makefile,做工精细

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 

仔细检查,这里面Main directory你可以致电

cqlsh -f "keyspaces/f1/bootstrap.cql" 

也许你可以委托给find

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

第一个使用'cat'的循环可以正常工作,但是,您在'Main directory'内建议运行的最后一行代码会抛出未找到的错误,所以我试图在Cassandra命令中出现错误运行:/我会发布更新,如果我弄明白了。谢谢! – Attila

+0

还有一个问题,也许代替makefile,你可以简单地使用find?找到'pwd' -name“* .cql”-exec cqlsh -f {} \; – mko

+0

它似乎工作,但是当我在循环中使用它时,我得到'find:-exec:no terminating“;”或“+”' – Attila

相关问题