running a batch file in #!/bin/bash

I installed git Extensions on my Windows pc. And you can run a bash script for every commit you do.
Now I created a .bat file with this in it.
 
cd C:\wamp\bin\mysql\mysql5.5.8\bin\
mysqldump -u root test > Databases/test.sql

Open in new window

And because Git can only use bash files, I wanted to make a bash script that opens this batch file.
 
#!/bin/sh

exec pre-commit.bat

Open in new window

I thought this was the solution, but it didn't work, I already browsed the web for hours, and I couldn't find an answer over there. So I hope you experts can give the solution.

I don't know if it's possible to run a batch script in a bash script, I hope this is possible, otherwise I'll need to search for a different approach.

Thanks in advance

Silencer001
Silencer001Asked:
Who is Participating?
 
Silencer001Connect With a Mentor Author Commented:
I did it

 
#!/bin/bash

cd ./.git/hooks
start pre-commit.bat

Open in new window


This is the solution and it works perfectly.

MikeOM_DBA thank you for putting me in the direction I needed to look.
0
 
MikeOM_DBAConnect With a Mentor Commented:
Try this:

#!/bin/bash

cmd /c pre-commit.bat

Open in new window

0
 
Silencer001Author Commented:
Didn't do the trick.

But as you can see on this image it already opened the cmd in it.
 image of that it opens the cmd command but doesn't run the .bat
So I tried
 
#!/bin/bash

cmd 
cd /C 
start pre-commit.bat

Open in new window

And when I ran the program it said that it could find pre-commit.bat.
I'm going to try different approaches now, and hopefully me or you guys can come up with a solutions.
#!/bin/bash

cmd 
start pre-commit.bat

Open in new window

0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
MikeOM_DBACommented:
If I set you in the right direction, maybe you should assign me the points.
0
 
MikeOM_DBACommented:
It is unacceptable to provide correct assistance and then be screwed by the OP.
0
 
Silencer001Author Commented:
I already was in the good direction, the only thing you changed about it was replacing the exec with cmd /C. I thought the points were if you provide the correct answer?
0
 
MikeOM_DBACommented:
ok sorry.
All that OP needed was to add "cd ./.git/hooks" to the script.

0
 
Silencer001Author Commented:
Euhm MikeOM_DBA,

no didn't need to add that to the script.

It had to be start pre-commit.bat and not cmd /C. I really don't get it why you're making such a big deal out of this. You didn't provide the correct answer, my original thought was maybe better then yours. And you're being angry because you didn't get the points for a wrong answer?

And now you're 'lieing', try the thing you said, it doesn't work.
0
 
MikeOM_DBACommented:

/cygdrive/c/dba/KT>cat ./bashexec.sh
#!/bin/bash

cd ../.git/hooks
cmd /c pre-commit.bat

/cygdrive/c/dba/KT>cat ../.git/hooks/pre-commit.bat
echo ++++++++++++++++++++++++++++++
echo This is pre-commit.bat script
echo ++++++++++++++++++++++++++++++

/cygdrive/c/dba/KT>./bashexec.sh

C:\dba\.git\hooks>echo ++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++

C:\dba\.git\hooks>echo This is pre-commit.bat script
This is pre-commit.bat script

C:\dba\.git\hooks>echo ++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++
/cygdrive/c/dba/KT>

Open in new window

0
 
Silencer001Author Commented:
Did the trick.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.