Solved

VBScript command output stored in return value not piped to file?

Posted on 2008-10-28
2
514 Views
Last Modified: 2012-05-05
I have the following in a VBScript:

strTimeStamp=Year(NOW()) & "-" & Month(NOW()) & "-" & Day(NOW()) & "_" & Hour(NOW()) & "-" & Minute(NOW()) & "-" & Second(NOW())

strCmd=g_strDblQuote & g_strPathToMySQLDump & g_strDblQuote & " --add-drop-table --user=root --password=<password-here> --databases db > " & g_strSavePath & strTimeStamp & ".sql"

which is executed like this:
Set oExecObject = g_oShell.Exec(strCmd)
strReturnedValue=oExecObject.StdOut.ReadAll

for some reason the output is being stored in the variable that holds the return value, not the file specified in the command string. Can anyone tell me why this is and how I can correct it?
0
Comment
Question by:mark_667
  • 2
2 Comments
 
LVL 65

Accepted Solution

by:
RobSampson earned 125 total points
ID: 22836920
Hi, the pipe output character is not supported unliess you're running the command in a DOS box.  You can change the command from this:

strCmd=g_strDblQuote & g_strPathToMySQLDump & g_strDblQuote & " --add-drop-table --user=root --password=<password-here> --databases db > " & g_strSavePath & strTimeStamp & ".sql"

to this

strCmd="cmd /c " & g_strDblQuote & g_strPathToMySQLDump & g_strDblQuote & " --add-drop-table --user=root --password=<password-here> --databases db > " & g_strSavePath & strTimeStamp & ".sql"

and it should work.

Regards,

Rob.
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 22845827
Thanks for the grade.

Regards,

Rob.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

This tutorial will discuss fancy secure registration forms, with AJAX technology support. In this article I assume you already know HTML and some JS. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you mig…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

747 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now