[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

command line capture

Posted on 2005-04-14
6
Medium Priority
?
223 Views
Last Modified: 2012-05-05
Hi I'm using a bat file to compile java source.
I want to capture the results from that bat. but the strange thing is that the error debug printet from the compile is not returned!

vbnet code:
----------------------------------------------------
        Dim Proc As New Process,response as string
        Proc.StartInfo.FileName = "C:\Symbian\UIQ_21\erj\helloworld\compile.bat"
        Proc.StartInfo.Arguments = ""
        Proc.StartInfo.UseShellExecute = False
        Proc.StartInfo.RedirectStandardOutput = True
        Proc.StartInfo.CreateNoWindow = False
        Proc.Start()
        Proc.WaitForExit()
        response = Replace(Proc.StandardOutput.ReadToEnd(), vbFormFeed, "")
        response = Replace(response, vbLf, vbNewLine)

running the bat file in cmd line:
--------------------------------------------------------------------
source\HelloWorld.java:29: ';' expected
^
1 error
Failed to compile HelloWorld

but in the vb.net I get this :
---------------------------------------------------------------------
Failed to compile HelloWorld

compile.bat
-------------------------------------------------------------
@echo off
if "%epocroot%" == "" goto noepocroot
set appname=HelloWorld
set localclasspath=%epocroot%erj\ext\qawt.jar;%epocroot%erj\ext\util.jar;C:\Symbian\UIQ_21\erj\helloworld\generator\..\source;%epocroot%epoc32\java\ext\javaphone.jar;%epocroot%epoc32\java\lib\classes.zip;%epocroot%epoc32\tools\javalib

cd C:\Symbian\UIQ_21\erj\helloworld\generator\..\
if not exist C:\Symbian\UIQ_21\erj\helloworld\generator\..\code\ mkdir C:\Symbian\UIQ_21\erj\helloworld\generator\..\code
javac  -target 1.1 -classpath %localclasspath% -d code source\*.java

if errorlevel 1 goto failed
cd code
jar -cf ..\install\HelloWorld.jar *.class
cd ..
echo Successfully compiled HelloWorld
goto exit

:failed
echo Failed to compile HelloWorld
goto exit

:noepocroot
echo The environment variable 'epocroot' has not been set.
echo Ensure that it is set to where you installed the UIQ SDK.
echo E.g. C:\Symbian\UIQ_21\
goto exit

:exit
0
Comment
Question by:thor918
  • 4
  • 2
6 Comments
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 1000 total points
ID: 13783190
It's a long shot but I have always placed the call to ReadToEnd() BEFORE WaitForExit():

        response = Replace(Proc.StandardOutput.ReadToEnd(), vbFormFeed, "")
        Proc.WaitForExit()
        response = Replace(response, vbLf, vbNewLine)

See if that makes any difference.
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 13783214
You may have also to place the results of ReadToEnd() into a local temp string variable instead of directly into the Replace() command.
0
 
LVL 2

Author Comment

by:thor918
ID: 13783702
no it did not make any difference
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 2

Author Comment

by:thor918
ID: 13783729
not to confuse anyone with the bat to much I made one less complicated:
same result the debug info from javacompile is cut off:
compile.bat:
set appname=HelloWorld
set localclasspath=%epocroot%erj\ext\qawt.jar;%epocroot%erj\ext\util.jar;C:\Symbian\UIQ_21\erj\helloworld\generator\..\source;%epocroot%epoc32\java\ext\javaphone.jar;%epocroot%epoc32\java\lib\classes.zip;%epocroot%epoc32\tools\javalib

cd C:\Symbian\UIQ_21\erj\helloworld\generator\..\
javac  -target 1.1 -classpath %localclasspath% -d code source\*.java
0
 
LVL 2

Author Comment

by:thor918
ID: 13785073
ahhh.it was easy!
        Proc.StartInfo.RedirectStandardError = True
Proc.StandardError.ReadToEnd(),
and just read out the error stream. then I get the result I was looking for!
0
 
LVL 2

Author Comment

by:thor918
ID: 13790988
would be nice if anyone could show me to get the cmd runned totaly hidden.
as this code flashes the cmd line window
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

834 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