“没有这样的文件或目录”运行的Makefile脚本
问题描述:
的文件夹结构设置,像这样的时候:“没有这样的文件或目录”运行的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
命令,所以我不知道为什么我会得到错误。
答
我会用简单的步骤,开始以消除潜在的问题
.
├── 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 {} \;
'cat keyspaces/f1/bootstrap.cql'? – Beta