vbscript 调用 svnadmin dump
运行以下 vbscript 来调用 svnadmin dump 失败(即没有创建转储)
Set objShell = CreateObject("WScript.Shell")
Set objShellExec = objShell.Exec("svnadmin dump C:\svn_repos > C:\fullbackup")
我从另一篇文章中发现 svn dump因WScript.Shell失败,我必须使用cmd创建一个新的命令解释器,如下所示:
Set objShellExec = objShell.Exec("%comspec% /c" & "svnadmin dump C:\svn_repos > C:\fullbackup")
这成功创建了转储,但我永远无法读取输出信息(即*转储的修订版) 100. * 转储修订版 101. 等)。我尝试过
Do While objWshScriptExec.Status = 0
Wscript.Echo objShellExec.StdOut.Readline
Wscript.Echo objShellExec.StdErr.Readline
WScript.Sleep 100
Loop
,但没有显示任何内容。
我可以知道如何读取输出信息以及为什么在 svnadmin dump 命令正确执行之前需要使用“%comspec% /c”创建一个新的命令解释器?谢谢。
问候, Dexton
编辑代码:
Set objShell = CreateObject("WScript.Shell")
Set objFS = CreateObject("Scripting.FileSystemObject")
strOutput = "c:\svn_backup\fullbackupa"
Set objOutFile = objFS.CreateTextFile(strOutput,True)
Set objShellExec = objShell.Exec("%comspec% /c " & "svnadmin dump C:\svn_repos")
Do While objShellExec.Status = 0
stdoutline=objShellExec.StdOut.Readline
'Wscript.Echo stdoutline 'echo to standard output
Wscript.Echo objShellExec.StdErr.Readline
objOutFile.WriteLine(stdoutline & vbCrLf) 'write to file at the same time
WScript.Sleep 100
Loop
objOutFile.Close
解决方案:
Set objShell = CreateObject("WScript.Shell")
Set objFS = CreateObject("Scripting.FileSystemObject")
strOutput = "c:\svn_backup\fullbackupa"
Set objOutFile = objFS.CreateTextFile(strOutput,True)
Set objShellExec = objShell.Exec("%comspec% /c " & "svnadmin dump C:\svn_repos > c:\svn_backup\fullbackupb")
Do While objShellExec.Status = 0
stdoutline=objShellExec.StdErr.Readline
Wscript.Echo stdoutline 'echo to standard output
'Wscript.Echo objShellExec.StdErr.Readline
objOutFile.WriteLine(stdoutline & vbCrLf) 'write to file at the same time
WScript.Sleep 100
Loop
objOutFile.Close
Running the following vbscript to call svnadmin dump fails (i.e. no dump is being created)
Set objShell = CreateObject("WScript.Shell")
Set objShellExec = objShell.Exec("svnadmin dump C:\svn_repos > C:\fullbackup")
I discovered from another post, svn dump fails with WScript.Shell that i had to create a new command interpreter using cmd as follows:
Set objShellExec = objShell.Exec("%comspec% /c" & "svnadmin dump C:\svn_repos > C:\fullbackup")
This successfully created the dump but I could never read the output information (i.e. * Dumped revision 100. * Dumped revision 101. etc). I tried
Do While objWshScriptExec.Status = 0
Wscript.Echo objShellExec.StdOut.Readline
Wscript.Echo objShellExec.StdErr.Readline
WScript.Sleep 100
Loop
but nothing ever gets displayed.
May I know how i can read the output information and also why I needed to create a new command interpreter using "%comspec% /c" before the svnadmin dump command would execute correctly? Thanks.
Regards,
Dexton
Edited Code:
Set objShell = CreateObject("WScript.Shell")
Set objFS = CreateObject("Scripting.FileSystemObject")
strOutput = "c:\svn_backup\fullbackupa"
Set objOutFile = objFS.CreateTextFile(strOutput,True)
Set objShellExec = objShell.Exec("%comspec% /c " & "svnadmin dump C:\svn_repos")
Do While objShellExec.Status = 0
stdoutline=objShellExec.StdOut.Readline
'Wscript.Echo stdoutline 'echo to standard output
Wscript.Echo objShellExec.StdErr.Readline
objOutFile.WriteLine(stdoutline & vbCrLf) 'write to file at the same time
WScript.Sleep 100
Loop
objOutFile.Close
Solution:
Set objShell = CreateObject("WScript.Shell")
Set objFS = CreateObject("Scripting.FileSystemObject")
strOutput = "c:\svn_backup\fullbackupa"
Set objOutFile = objFS.CreateTextFile(strOutput,True)
Set objShellExec = objShell.Exec("%comspec% /c " & "svnadmin dump C:\svn_repos > c:\svn_backup\fullbackupb")
Do While objShellExec.Status = 0
stdoutline=objShellExec.StdErr.Readline
Wscript.Echo stdoutline 'echo to standard output
'Wscript.Echo objShellExec.StdErr.Readline
objOutFile.WriteLine(stdoutline & vbCrLf) 'write to file at the same time
WScript.Sleep 100
Loop
objOutFile.Close
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您无法读取状态,因为您将所有标准输出重定向到
c:\fullbackup
。您应该打开文件c:\fullbackup
并读取内容。更新:您可以将状态写入输出文件,如下所示
you can't read the status because you are redirecting all your stdout to
c:\fullbackup
. You should open the filec:\fullbackup
and read the contents instead.Update: you can write your status to an output file, something like this