Solved

running a batch file in #!/bin/bash

Posted on 2011-03-22
11
2,696 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
 
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Background Still having to process all these year-end "csv" files received from all these sources (including Government entities), sometimes we have the need to examine the contents due to data error, etc... As a "Unix" shop, our only readily …
Utilizing an array to gracefully append to a list of EmailAddresses
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

762 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now