Solved

running a batch file in #!/bin/bash

Posted on 2011-03-22
11
2,792 Views
Last Modified: 2013-12-26
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
0
Comment
Question by:Silencer001
  • 5
  • 5
11 Comments
 
LVL 29

Assisted Solution

by:MikeOM_DBA
MikeOM_DBA earned 50 total points
ID: 35197404
Try this:

#!/bin/bash

cmd /c pre-commit.bat

Open in new window

0
 

Author Comment

by:Silencer001
ID: 35198858
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
 

Accepted Solution

by:
Silencer001 earned 0 total points
ID: 35199637
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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 29

Expert Comment

by:MikeOM_DBA
ID: 35202641
If I set you in the right direction, maybe you should assign me the points.
0
 
LVL 29

Expert Comment

by:MikeOM_DBA
ID: 35202680
It is unacceptable to provide correct assistance and then be screwed by the OP.
0
 

Author Comment

by:Silencer001
ID: 35204834
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
 
LVL 29

Expert Comment

by:MikeOM_DBA
ID: 35216689
ok sorry.
All that OP needed was to add "cd ./.git/hooks" to the script.

0
 

Author Comment

by:Silencer001
ID: 35226001
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
 
LVL 29

Expert Comment

by:MikeOM_DBA
ID: 35226084

/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
 

Author Closing Comment

by:Silencer001
ID: 35230186
Did the trick.
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Over the years I've spent many an hour playing on hardened, DMZ'd servers, with only a sub-set of the usual GNU toy's to keep me company; frequently I've needed to save and send log or data extracts from these server back to my PC, or to others, and…
Recently, an awarded photographer, Selina De Maeyer (http://www.selinademaeyer.com/), completed a photo shoot of a beautiful event (http://www.sintjacobantwerpen.be/verslag-en-fotoreportage-van-de-sacramentsprocessie-door-antwerpen#thumbnails) in An…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question