Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bash on cygwin: No such file or directory

Tags:

bash

cygwin

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

like image 327
MetaChrome Avatar asked Dec 28 '25 06:12

MetaChrome


2 Answers

Cygwin will actually do magic for you if you put your DOS paths in quotes, for example

cd "C:\Program Files\"
like image 110
RandomMonkey Avatar answered Dec 30 '25 22:12

RandomMonkey


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.

like image 22
krock Avatar answered Dec 30 '25 22:12

krock