Advertisement

07.15.2005 at 12:54AM PDT, ID: 21492590
[x]
Attachment Details

Execute Command Line With Arguements And Has Standard Output

Asked by xmlnewbie in Microsoft Visual Basic.Net

Tags: error, output

I'm trying to execute saxon (XSLT command line parser) from VB.NET. From the DOS prompt, I have no problem doing so. However, my VB.NET application seems to refuse to work properly. Here's what I want to execute:

' Works in DOS
saxon -o output.xml input.xml transform.xsl 2>error.txt

Basically, the above command passes an input XML file and XSLT transformation script, defines the output file and sends any errors to standard output into error.txt.

Here's what I am trying to do in VB.NET

' Let's assume all these files are in the execution directory
Dim p as New System.Diagnostics.Process
p.StartInfo.FileName = "saxon.exe"
p.StartInfo.Arguments =" -o output.xml input.xml transform.xsl 2>error.txt"
p.StartInfo.RedirectStandardOutput = True
p.StartInfo.UseShellExecute = False   ' does this prevent the DOS window from showing?
p.Start

Dim a As String = p.StandardOutput.ReadToEnd
MesssageBox.Show(a)     ' always shows null string even when something should be there

Also, the transformation does not occur when the arguements include "2>error.txt." If I remove that from the arguements, the transformation works just fine -- except now I don't have my error log.

What's the proper way to execute a command line application with arguements that send to the standard output?Start Free Trial
[+][-]07.15.2005 at 04:43AM PDT, ID: 14449701

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.15.2005 at 10:23AM PDT, ID: 14453079

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.17.2005 at 12:28AM PDT, ID: 14460566

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Microsoft Visual Basic.Net
Tags: error, output
Sign Up Now!
Solution Provided By: kiphughes
Participating Experts: 2
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32