Solved

running a batch file in #!/bin/bash

Posted on 2011-03-22
11
2,876 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Unix process listing into CSV format 3 46
How do I monitor a folder and email changes once a day? 12 101
shell script to send sms 2 219
VBA Shell can't Find Word document 11 125
This Windows batch file is useful for organizing image files from a digital camera or other source, but can have many other uses.  It simply renames the file(s) to match their create date.  For example, if you took a picture today at 1:40pm and the …
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

679 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