Bash on cygwin: No such file or directory
commonMongo=s:/programs/mongodb/
dbpath=$commonMongo"data/"
logFile=$commonMongo"log.txt"
mongoProg=s:/programs/mongodb/mongodb/
mongoBin=$mongoProg"bin/"
mongod=$mongoBin"mongod.exe"
a=$1
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
Calling the printed command works fine:
s:/programs/mongodb/mongodb/bin/mongod.exe --dbpath s:/programs/mongodb/data/ --repair
Cygwin will actually do magic for you if you put your DOS paths in quotes, for example
cd "C:\Program Files\"
Cygwin does not recognize Windows drive letters such as s:
, use /cygdrive/s
instead. Your cygwin command should look like this:
/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.exe
is not a Cygwin binary.
To make it easier, you could add mongod.exe
your path, then you do not need to specify the directory it is in.
精彩评论