Bash on cygwin:没有这样的文件或目录
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7629017/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Bash on cygwin: No such file or directory
提问by MetaChrome
commonMongo=s:/programs/mongodb/
dbpath=$commonMongo"data/"
logFile=$commonMongo"log.txt"
mongoProg=s:/programs/mongodb/mongodb/
mongoBin=$mongoProg"bin/"
mongod=$mongoBin"mongod.exe"
a=
if [ "$a" == "start" ];then
"${mongod} --logpath ${logFile} --logappend --dbpath ${dbpath} &"
elif [ "$a" == "repair" ];then
"${mongod} --dbpath ${dbpath} --repair"
else
echo "Incorrect usage"
fi
./init.sh: line 11: s:/programs/mongodb/mongodb/bin/mongod.exe --dbpath s:/programs/mongodb/data/ --repair: No such file or directory
./init.sh: line 11: s:/programs/mongodb/mongodb/bin/mongod.exe --dbpath s:/programs/mongodb/data/ --repair: 没有那个文件或目录
Calling the printed command works fine:
调用打印命令工作正常:
s:/programs/mongodb/mongodb/bin/mongod.exe --dbpath s:/programs/mongodb/data/ --repair
s:/programs/mongodb/mongodb/bin/mongod.exe --dbpath s:/programs/mongodb/data/ --repair
回答by RandomMonkey
Cygwin will actually do magic for you if you put your DOS paths in quotes, for example
例如,如果您将 DOS 路径放在引号中,Cygwin 实际上会为您施展魔法
cd "C:\Program Files\"
回答by krock
Cygwin does not recognize Windows drive letters such as s:, use /cygdrive/sinstead. Your cygwin command should look like this:
Cygwin 无法识别 Windows 驱动器号,例如s:,请/cygdrive/s改用。您的 cygwin 命令应如下所示:
/cygdrive/s/programs/mongodb/mongodb/bin/mongod.exe --dbpath s:/programs/mongodb/data/ --repair
Notice that the path like parameters you pass to the executable are in windows format as mongod.exeis not a Cygwin binary.
请注意,您传递给可执行文件的类似参数的路径是 Windows 格式,mongod.exe而不是 Cygwin 二进制文件。
To make it easier, you could add mongod.exeyour path, then you do not need to specify the directory it is in.
为了方便起见,您可以添加mongod.exe您的路径,然后您不需要指定它所在的目录。

