Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Process.Start from a web service and StandardOutput

Reply
Thread Tools

Process.Start from a web service and StandardOutput

 
 
Steve B.
Guest
Posts: n/a
 
      04-07-2006
Hi,

I'm written a Web Service that encapsulate the call to a command line
application.
The command line application is run using Process.Start, and I'd like to get
both standard ouput and standard error to create a log.

After some searches, I finally wrote this part of code :

public class MyClass {

private StreamWriter sw; // A Streamwriter where we can write the log
private Process p;

public void DoSomething(
string arg,
Stream outputStream
)
{
try
{
this.sw = new StreamWriter(outputStream); // An output stream will contains
the log

p = new Process();
p.StartInfo.FileName = "c:\\myapp.exe";
p.StartInfo.Arguments = string.Format(
"myarg=\"{0}\"",
arg
);
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.OutputDataReceived += new DataReceivedEventHandler(p_OutputDataReceived);
p.ErrorDataReceived += new DataReceivedEventHandler(p_ErrorDataReceived);
p.Start();
p.WaitForExit();
}
catch (Exception exc)
{
sw.WriteLine(exc.ToString());
throw exc;
}
}
void p_ErrorDataReceived(object sender, DataReceivedEventArgs e)
{
sw.Write(e.Data);
}

private void p_OutputDataReceived(object sender, DataReceivedEventArgs e)
{
sw.Write(e.Data);
}

}

Is it the right way ?

Thanks,
Steve


 
Reply With Quote
 
 
 
 
sirfunusa
Guest
Posts: n/a
 
      04-07-2006
MyApp is going to run on the server, you know that, right? Spawning
apps like this is never a good idea. What does the app do?

 
Reply With Quote
 
 
 
 
Steve B.
Guest
Posts: n/a
 
      04-10-2006
The app actually runs on the server.
It is command line that can sign some assemblies using SIGNTOOL.EXE.

The Web Service is used to maintain a device application auto update feature
based on CAB files that must be signed with a certificate.

I send the raw dll and exe files to the webservice, and the WS first create
the cabfile using makecab (well working), and then sign the output cab with
SIGNTOOL.EXE (not well working).

Since it does not work, I want to get the process output to return to the
user in order to know why it did not worked.

I agree Process.Start and derivated in a WS is not a nice solution, but
building the full mecanims of creating and signing cab files is surely quite
complex. That's why we decided to use the existing tools, even if they are
command line tools.

We'll stay on this solution for now because of a release soon, but if you
have suggestion on other solution, we listen

Thanks,
Steve

"sirfunusa" <(E-Mail Removed)> a écrit dans le message de news:
(E-Mail Removed) om...
> MyApp is going to run on the server, you know that, right? Spawning
> apps like this is never a good idea. What does the app do?
>



 
Reply With Quote
 
Steve B.
Guest
Posts: n/a
 
      04-10-2006
In orderto test, I've an incredibly complex command line app :

public static void Main()
{
Console.WriteLine("Bonjour");
for (int i = 0; i < 100; i++)
{
Console.Write(i.ToString("00") + " ");
Thread.Sleep(25);
}
Console.WriteLine("\nFini");
}

Running this command line within a WS does not produce any output...

Thanks,
Steve

"Steve B." <(E-Mail Removed)_swap_com_and_msn> a écrit dans le message
de news: %(E-Mail Removed)...
> The app actually runs on the server.
> It is command line that can sign some assemblies using SIGNTOOL.EXE.
>
> The Web Service is used to maintain a device application auto update
> feature based on CAB files that must be signed with a certificate.
>
> I send the raw dll and exe files to the webservice, and the WS first
> create the cabfile using makecab (well working), and then sign the output
> cab with SIGNTOOL.EXE (not well working).
>
> Since it does not work, I want to get the process output to return to the
> user in order to know why it did not worked.
>
> I agree Process.Start and derivated in a WS is not a nice solution, but
> building the full mecanims of creating and signing cab files is surely
> quite complex. That's why we decided to use the existing tools, even if
> they are command line tools.
>
> We'll stay on this solution for now because of a release soon, but if you
> have suggestion on other solution, we listen
>
> Thanks,
> Steve
>
> "sirfunusa" <(E-Mail Removed)> a écrit dans le message de news:
> (E-Mail Removed) om...
>> MyApp is going to run on the server, you know that, right? Spawning
>> apps like this is never a good idea. What does the app do?
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Does timer in Web Service Global.asax block my Web Service from processing web-site requests? Leo Violette ASP .Net Web Services 0 04-17-2009 12:39 AM
'web service call failed: 500' using ajax hovermenu and web service Not Me ASP .Net 1 06-05-2007 03:09 PM
ASP 1.1 - StandardOutput from console application Harald Fichtner ASP .Net 1 10-06-2006 08:17 PM
process StandardOutput Security Inquiry shellyshao ASP .Net Security 0 02-16-2006 01:27 AM
InvocationTargetException when calling "new Service()" in Axis web service to call another web service Michael Averstegge Java 0 01-10-2006 11:05 PM



Advertisments