Solved

running a batch file in #!/bin/bash

Posted on 2011-03-22
11
3,016 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Want Experts Exchange at your fingertips?

With Experts Exchange’s latest app release, you can now experience our most recent features, updates, and the same community interface while on-the-go. Download our latest app release at the Android or Apple stores today!

Question has a verified solution.

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

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 …
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
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…
Suggested Courses

630 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