【发布时间】:2012-02-13 00:38:44
【问题描述】:
我试图通过调用 wsh jscript 文件来转储 mysql 数据库,但它不起作用。
我有这段代码,用 git shell 调用,它运行良好:
# 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"
我在 WSH 中尝试了几乎相同的代码,但它只返回转储文件的标题,并且不创建文件。我不知道出了什么问题,或者如何调试代码......: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());
我也尝试过使用 bat 文件和 cmd 文件,但它们无法处理路径中的空间。
有人可以帮忙吗?
(对我来说,以某种方式从 git 代码生成可执行文件或使 wsh 工作就足够了……完美的解决方案是如果我可以从 netbeans 调用转储,但在生活中没有什么比这更理想的了。 .. :D)
【问题讨论】:
标签: windows git exec mysqldump wsh