ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> perl.net
perl.net
Re: pure perl and c# - catch errors when executing script
by Dan Jablonsky other posts by this author
Feb 17 2005 11:37AM messages near this date
view in the new Beta List Site
pure perl and c# - catch errors when executing script | RE: PerlNet debug issue...
FRAMEWORK 
--- Dan Jablonsky <vv_2010@[...].com>  wrote:

>  Hi all,
>  i have the following code in a c# application:
>  
>  public void execscript()
>  {
>    Process myprocess = new Process();
>    try
>       {
>  	string perl_script = "err0.pl";
>  	myprocess.StartInfo.FileName "c:\\perl_dev\\" +
>  perl_script;
>  	myprocess.StartInfo.CreateNoWindow = false;
>  	myprocess.StartInfo.WindowStyle =
>  ProcessWindowStyle.Maximized;
>  	myprocess.StartInfo.UseShellExecute = true;
>  	myprocess.Start();
>  	myprocess.WaitForExit(10000);
>  	EventLog.WriteEntry("exterr", "test mesg");
>  	myprocess.Close();
>       }
>  catch (Exception e)
>       {
>  	throw new System.Exception();
>       }
>  }
>  
>  I need to catch an error raised in the script.
>  Right now the script contains only one line:
>  #!perl
>  die("died here");
>  Unfortunatelly, I can catch an error like "file not
>  found", "no permission" BUT I CANNOT CATCH THE
>  die().
>  I tried to replace die with exit(255) and I tried to
>  execute something that would definetely issue an
>  error
>  from Perl - nothing worked.
>  
>  Any idea how to do it?
>  
>  Thanks,
>  Dan
>  
>  
OK,
mistery solved.
I guess my question was related more to the handling
of the myprocess object above, rather than how to
issue the error in Perl.
It just happens that Process has a StandardError
method, hence myprocess.StandardError.ToString();
anywhere after myprocess.Start() will issue a
System.Exception taht will be prompltly caught.

Thanks for your help,
Dan


		
__________________________________ 
Do you Yahoo!? 
Take Yahoo! Mail with you! Get it on your mobile phone. 
http://mobile.yahoo.com/maildemo 
_______________________________________________
Perl.NET mailing list
Perl.NET@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Thread:
Dan Jablonsky
Dan Jablonsky

Privacy Policy | Email Opt-out | Feedback | Syndication
© 2004 ActiveState, a division of Sophos All rights reserved