Problem in capturing Dos application messages C#

H

Harikumar G

Friends,

I have a C# console application for verifying a signature of an encrypted,
this is done thru the Process.Startinfo method,

My dos application for the decryption is gpg.exe (gnupgi)

When I tried from the dos prompt the folloing output received:

------------------------------------------------------------------------
C:\Processor\bin\Debug>gpg --decrypt file4.gpg
gpg: encrypted with 2048-bit ELG-E key, ID C51C8CA2, created 2004-11-06
"FTSA_KEY (test_key)"
Chassis Type : R200
Chassis Mode : JubiNet
Software Version : MAIN4.4.2.218

Slot Item Serial Number Part Number Revision
--------------------------------------------------------------
E1200 E000000001664 6000003000 03
0 CC-E-SFM 0005072 7490033602 01
4 CC-E-SFM 0005074 7490033602 01
5 CC-E-SFM 0006771 7520003700 2
0 CC-E1200-PWR-DC N/A N/A N/A
0 CC-E1200-FAN N/A N/A N/A
5 CC-E1200-FAN N/A N/A N/A

* - standby

gpg: Signature made 11/06/04 11:16:19 using DSA key ID A94AF57D
gpg: Good signature from "Agent00017555 (test key for Hari)
<[email protected]>"
gpg: WARNING: This key is not certified with a trusted signature!
gpg: There is no indication that the signature belongs to the
owner.
Primary key fingerprint: C549 E5F1 FD6F 8AFE C5F3 B058 348D 3840 A94A F57D

C:\Processor\bin\Debug>

----------------------------------------------------------------------------
---

I need all the output for the purpose of varifying the signature including
the gpg messages

but when I tried from my application, only the file contents is getting
extracted

The output from my application is as follows like this
-------------------------------------------------------------------------

Chassis Type : R200
Chassis Mode : JubiNet
Software Version : MAIN4.4.2.218

Slot Item Serial Number Part Number Revision
--------------------------------------------------------------
E1200 E000000001664 6000003000 03
0 CC-E-SFM 0005072 7490033602 01
4 CC-E-SFM 0005074 7490033602 01
5 CC-E-SFM 0006771 7520003700 2
0 CC-E1200-PWR-DC N/A N/A N/A
0 CC-E1200-FAN N/A N/A N/A
5 CC-E1200-FAN N/A N/A N/A

* - standby


-------------------------------------------------------------------------


How can I get the application messages text also as the part of output
string?

My method as follows:

public static bool VarifyKey()
{
try
{
Process MyProc = new Process();
MyProc.StartInfo.FileName = "gpg.exe";
MyProc.StartInfo.CreateNoWindow = true;
MyProc.StartInfo.UseShellExecute = false;
MyProc.StartInfo.RedirectStandardOutput = true;

MyProc.StartInfo.Arguments = "--decrypt file4.gpg";
MyProc.Start();
//#capture results
string output = MyProc.StandardOutput.ReadToEnd();

if (!MyProc.WaitForExit(10000))
{
MyProc.Close();
return false;
}
if (MyProc.ExitCode != 0) // Decrypt Error -inside pg (unknown)
{
MyProc.Close();
return false;
}
int index = output.Trim().IndexOf("Good signature");
if (int = -1)
{return false;}
}
}

thanks
-hari
 
J

Jon Skeet [C# MVP]

Harikumar G said:
Friends,

I have a C# console application for verifying a signature of an encrypted,
this is done thru the Process.Startinfo method,

My dos application for the decryption is gpg.exe (gnupgi)

When I tried from the dos prompt the folloing output received:

<snip>

Have you tried reading StandardError as well as StandardOutput?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top