Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7511543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T23:34:50+00:00 2026-05-29T23:34:50+00:00

I tried to dump a mysql database with calling a wsh jscript file, but

  • 0

I tried to dump a mysql database with calling a wsh jscript file, but it doesn’t work.

I have this code, called with git shell, and it works perfectly:

# If something fails, exit with status other than 0
set -e

# select dump directory
cd "$(git rev-parse --show-toplevel)"

# first, remove our original schema
rm -f "WebShop\DataBase\backup.sql"

# generate a new schema
exec "C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqldump.exe" --skip-comments -u root --password=root webshopdb |sed 's$),($),\n($g' > "WebShop\DataBase\backup.sql"

I tried almost the same code in WSH, but it returns only with the header of the dump file, and doesn’t creates the file. I do not have a clue what is working wrong, or how to debug the code… :S

var shellObj = WScript.CreateObject('WScript.Shell');
var exec = shellObj.Exec(
    '"C:\\Program Files\\MySQL\\MySQL Server 5.5\\bin\\mysqldump.exe"'+
    " --skip-comments -u root --password=root webshopdb |sed 's$),($),\\n($g' > " + 
    '"D:\\creation\\software developer\\projects\\webshop-refactoring-project\\document root\\WebShop\\DataBase\\backup.sql"'
);
WScript.Echo(exec.StdOut.ReadAll());

I tried with bat files and cmd files too, but they cannot handle the space in the pathes.

Can anybody help?

(For me it would be enough to make somehow an executable from the git code, or make the wsh work… The perfect solution would be if I could call the dump from netbeans, but in life nothing is so ideal… 😀 )

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T23:34:51+00:00Added an answer on May 29, 2026 at 11:34 pm

    I made it with file association.

    I created a git.bat file:

    if not exist %1 exit
    set bash=C:\Program Files (x86)\Git\bin\bash.exe
    "%bash%" --login -i -c "exec "%1""
    

    And associated it to .hook files.

    After that I created a test dump.hook file:

    #!/bin/sh
    cd "D:/creation/software developer/projects/webshop-refactoring-project/document root/WebShop";
    cd "$(git rev-parse --show-toplevel)"
    rm -f "WebShop/DataBase/backup.sql"
    exec "C:/Program Files/MySQL/MySQL Server 5.5/bin/mysqldump.exe" --skip-comments -u root --password=root webshopdb |sed 's$),($),\n($g' > "WebShop/DataBase/backup.sql"
    exit
    

    And it works perfectly.

    After 3 days I got it! Woohoo! 😀

    note: *Windows command prompt usually has problems with whitespace and special characters in the path name, so it is much easier to use the emulated linux of git, than try to fix it. It is possible to source the .hook file into a pre-commit git hook too, so it can automatically dump the database schema by every commit… (maybe the git add not working by those files, I haven’t found an auto dump and commit solution yet: git pre-commit + mysqldump: cannot find path, not existing command) *

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here the thing, other PDO works well, but this one doesn't. I have tried
Please help, I got this code from googling on how to use mysql dump
I have taken a dump from my mysql database on my own server (version
I am trying to restore MySQL database data from a dump file, using C#
When I tried to establish a MySQL database using a dump, I got the
Tried this: $('.link').click(function(e) { $.getScript('http://www.google.com/uds/api?file=uds.js&amp;v=1.0', function() { $('body').append('<p>GOOGLE API (UDS) is loaded</p>'); }); return
Tried a bunch of things but I can't get it to work consistently amid
I've tried using mysql dump in the command line and it worked. How do
This may be a n00b topic but, anyways, I have been having a rather
I've tried doing my research on this, found this website: http://www.lullabot.com/blog/importexport-large-mysql-databases and still am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.