I am seeing a problem when I put the Process routine in a seperate
"class library" project. Here is my code:
public void RunExportUtility (Credential c, string
parameterFileName)
{
// Start a new process to run the EXP utility
Process myApp = new Process();
myApp.StartInfo.WorkingDirectory="C:\\Documents and
Settings\\palessi\\My Documents\\Visual Studio
Projects\\Training\\TrainingAdmin\\bin\\Debug";
myApp.StartInfo.CreateNoWindow=false;
myApp.StartInfo.FileName = "C:\\oracle\\ora92\\bin\\EXP.EXE";
myApp.StartInfo.Arguments = c.Username + "/" + c.Password + "@" +
c.Database + " parfile=" + parameterFileName + ".par";
myApp.StartInfo.UseShellExecute = false;
myApp.StartInfo.RedirectStandardOutput=true;
myApp.Start();
Debug.WriteLine("TEST:" + myApp.StandardOutput.ReadToEnd());
myApp.WaitForExit();
/* The field OnExportComplete will either be null, if no client has
hooked up a delegate to the event
* , or else it refers to a delegate that should be called when the
event is invoked.
* Thus, invoking an event is generally done by first checking for
null and then calling the event.
*/
if (OnExportComplete != null)
// Raise the export complete event
OnExportComplete(this,new EventArgs());
}
All it does is take a credential and run the Oracle EXP utility. The
redirection goes to the output window in the IDE, but it isn't
prefixed with TEXT:. TEXT: is at the end of the output like so:
Export: Release 9.2.0.1.0 - Production on Tue Feb 10 13:55:04 2004
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Connected to: Oracle9i Enterprise Edition Release 9.2.0.4.0 -
Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.4.0 - Production
Export done in WE8MSWIN1252 character set and AL16UTF16 NCHAR
character set
server uses US7ASCII character set (possible charset conversion)
Note: grants on tables/views/sequences/roles will not be exported
Note: constraints on tables will not be exported
About to export specified tables via Conventional Path ...
.. . exporting table ACFP_ACFT_TY 43 rows
exported
EXP-00091: Exporting questionable statistics.
EXP-00091: Exporting questionable statistics.
.. . exporting table ACFP_ACFT_TY_XREF 25 rows
exported
EXP-00091: Exporting questionable statistics.
EXP-00091: Exporting questionable statistics.
.. . exporting table ACFT 13587 rows
exported
EXP-00091: Exporting questionable statistics.
EXP-00091: Exporting questionable statistics.
.. . exporting table ACFT_ALPHA_CD_DOM 3 rows
exported
EXP-00091: Exporting questionable statistics.
EXP-00091: Exporting questionable statistics.
Export terminated successfully with warnings.
TEST:
The program '[2016] TrainingAdmin.exe' has exited with code 0 (0x0).
Any idea why this is happening? Basically my goal is to be able to
parse the output of EXP in real time and raise events to the calling
app which contain the name of the table being exported.
Any help would be greatly appreciated!
Pat
"Garrett" <ga********************@NOSPAMhotmail.com> wrote in message news:<#d**************@TK2MSFTNGP10.phx.gbl>...
Sorry to answer myself...
I've worked at little more on my previously posted examples.
Test before using. :-)
------------Example 1----------------
using System;
using System.IO;
using System.Diagnostics;
using System.ComponentModel;
class test{
static void Main()
{
System.Diagnostics.Process myProcess = new System.Diagnostics.Process();
myProcess.StartInfo.FileName = "systeminfo";
myProcess.StartInfo.UseShellExecute = false;
myProcess.StartInfo.CreateNoWindow = false;
myProcess.StartInfo.RedirectStandardInput = true;
myProcess.StartInfo.RedirectStandardOutput = true;
myProcess.StartInfo.RedirectStandardError = true;
myProcess.Start();
StreamWriter sIn = myProcess.StandardInput;
StreamReader sOut = myProcess.StandardOutput;
StreamReader sErr = myProcess.StandardError;
string s = sOut.ReadToEnd();
Console.WriteLine(s);
sIn.Close();
sOut.Close();
myProcess.Close();
}
}
-----------end example1------------
-----------Example 2----------------
using System;
using System.IO;
using System.Diagnostics;
using System.ComponentModel;
class test{
static void Main()
{
System.Diagnostics.Process myProcess = new System.Diagnostics.Process();
myProcess.StartInfo.FileName = "cmd.exe";
myProcess.StartInfo.UseShellExecute = false;
myProcess.StartInfo.CreateNoWindow = false;
myProcess.StartInfo.RedirectStandardInput = true;
myProcess.StartInfo.RedirectStandardOutput = true;
myProcess.StartInfo.RedirectStandardError = true;
myProcess.Start();
StreamWriter sIn = myProcess.StandardInput;
StreamReader sOut = myProcess.StandardOutput;
StreamReader sErr = myProcess.StandardError;
sIn.WriteLine("systeminfo");
sIn.WriteLine("exit");
//myProcess.WaitForExit(); -- This hangs the program
string s = sOut.ReadToEnd();
Console.WriteLine(s);
sIn.Close();
sOut.Close();
myProcess.Close();
}
}
---------end example 2--------------
"Garrett" <ga********************@NOSPAMhotmail.com> wrote in message
news:Oh**************@TK2MSFTNGP11.phx.gbl... And here is a second example I've been playing with.
Should have posted this with my first post.
This also doesn't seem to work with systeminfo.
using System;
using System.IO;
using System.Diagnostics;
using System.ComponentModel;
class test{
static void Main()
{
System.Diagnostics.Process myProcess = new System.Diagnostics.Process();
myProcess.StartInfo.FileName = "cmd.exe";
myProcess.StartInfo.UseShellExecute = false;
myProcess.StartInfo.CreateNoWindow = false;
myProcess.StartInfo.RedirectStandardInput = true;
myProcess.StartInfo.RedirectStandardOutput = true;
myProcess.StartInfo.RedirectStandardError = true;
myProcess.Start();
StreamWriter sIn = myProcess.StandardInput;
StreamReader sOut = myProcess.StandardOutput;
StreamReader sErr = myProcess.StandardError;
sIn.WriteLine("ping 127.0.0.1");
sIn.WriteLine("exit");
myProcess.WaitForExit();
string s = sOut.ReadToEnd();
Console.WriteLine(s);
sIn.Close();
sOut.Close();
myProcess.Close();
}
}
"Tommy Lu" <lu****@email.msn.com> wrote in message
news:uU**************@TK2MSFTNGP12.phx.gbl... Hi, wondering if there is a way to interact the shell command with the
C# program? For example, if I type
c:\>ver
it then suppose to return the version of the OS I am currently using...
or
c:\>systeminfo
then it will return a list of information of my currently system, and
what I want to do is to catch these information and use it in my c#
program?
Is there a way to do that?
Thank you all for the help.
Sincerely
Tommy
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!