<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/172614</link>
    <title>MATLAB Central Newsreader - &quot;program terminated&quot; message by mail</title>
    <description>Feed for thread: &quot;program terminated&quot; message by mail</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Tue, 15 Jul 2008 22:22:02 -0400</pubDate>
      <title>&quot;program terminated&quot; message by mail</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/172614#443265</link>
      <author>AHMET ANIL DINDAR</author>
      <description>Hi,&lt;br&gt;
I've been doing a long-hours-run analysis in MATLAB in which&lt;br&gt;
I used &quot;sendmail&quot; in several parts of the script with the&lt;br&gt;
intention of having been informed about the process. It&lt;br&gt;
worked superb till now.&lt;br&gt;
&lt;br&gt;
However, my analysis program terminates due to several&lt;br&gt;
reasons. At such moment, I follow the incoming mails and&lt;br&gt;
find the last action in the process. Is it possible to write&lt;br&gt;
a code that runs my program and checks whether it is running&lt;br&gt;
or not? And in case of termination the code sends an e-mail&lt;br&gt;
message.&lt;br&gt;
&lt;br&gt;
Any idea?&lt;br&gt;
&lt;br&gt;
thanks in advance.&lt;br&gt;
&lt;br&gt;
ahmet_anil_dindar</description>
    </item>
    <item>
      <pubDate>Tue, 15 Jul 2008 22:34:49 -0400</pubDate>
      <title>Re: &quot;program terminated&quot; message by mail</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/172614#443268</link>
      <author>roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)</author>
      <description>In article &amp;lt;g5j7ua$s3u$1@fred.mathworks.com&amp;gt;,&lt;br&gt;
AHMET ANIL DINDAR &amp;lt;adindar@iku.edu.tr&amp;gt; wrote:&lt;br&gt;
&amp;gt;Is it possible to write&lt;br&gt;
&amp;gt;a code that runs my program and checks whether it is running&lt;br&gt;
&amp;gt;or not? And in case of termination the code sends an e-mail&lt;br&gt;
&amp;gt;message.&lt;br&gt;
&lt;br&gt;
Yes.&lt;br&gt;
&lt;br&gt;
The ease of doing so will depend greatly upon which operating&lt;br&gt;
system you are using, which you have not stated. It would&lt;br&gt;
be automatic in Unix if you start the Matlab run using the &quot;batch&quot;&lt;br&gt;
command.&lt;br&gt;
&lt;br&gt;
-- &lt;br&gt;
&amp;nbsp;&amp;nbsp;&quot;They called it golf because all the other four letter words&lt;br&gt;
&amp;nbsp;&amp;nbsp;were taken.&quot;                                    -- Walter Hagen</description>
    </item>
    <item>
      <pubDate>Wed, 16 Jul 2008 06:20:19 -0400</pubDate>
      <title>Re:</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/172614#443321</link>
      <author>AHMET ANIL DINDAR</author>
      <description>Thanks for the answer. I didn't know the OS was important&lt;br&gt;
for such a program since I'm not an expert on programming. &lt;br&gt;
Anyway, I'm using XP in my comp. Is there still a chance to&lt;br&gt;
use the &quot;batch&quot; command?&lt;br&gt;
&lt;br&gt;
thanks again.</description>
    </item>
    <item>
      <pubDate>Wed, 16 Jul 2008 07:42:02 -0400</pubDate>
      <title>Re:</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/172614#443329</link>
      <author>Rodney Thomson</author>
      <description>&quot;AHMET ANIL DINDAR&quot; &amp;lt;adindar@iku.edu.tr&amp;gt; wrote in message&lt;br&gt;
&amp;lt;g5k3v3$ruc$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Thanks for the answer. I didn't know the OS was important&lt;br&gt;
&amp;gt; for such a program since I'm not an expert on programming. &lt;br&gt;
&amp;gt; Anyway, I'm using XP in my comp. Is there still a chance to&lt;br&gt;
&amp;gt; use the &quot;batch&quot; command?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; thanks again.&lt;br&gt;
&lt;br&gt;
One thing you could possibly do is put a try/catch block in&lt;br&gt;
your mainline that encompasses all of your code. And then on&lt;br&gt;
any errors you can send an email notifying the source and&lt;br&gt;
reason of the error.&lt;br&gt;
&lt;br&gt;
In the catch block you could do something like:&lt;br&gt;
&lt;br&gt;
catch&lt;br&gt;
&amp;nbsp;&amp;nbsp;err = lasterror;&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;error_message = sprintf('Error: %s::%s\nOccured in %s::%s&lt;br&gt;
at line %d\n', err.identifier, err.message, err.stack.file,&lt;br&gt;
err.stack.name, err.stack.line);&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;sendmail('uhoh@itdied.com', 'Matlab process crashed',&lt;br&gt;
error_message);&lt;br&gt;
end&lt;br&gt;
&lt;br&gt;
NOTE: I've not run this code so treat it as pseudocode&lt;br&gt;
&lt;br&gt;
--&lt;br&gt;
&lt;a href=&quot;http://iheartmatlab.blogspot.com&quot;&gt;http://iheartmatlab.blogspot.com&lt;/a&gt;</description>
    </item>
    <item>
      <pubDate>Fri, 18 Jul 2008 15:52:02 -0400</pubDate>
      <title>Re:</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/172614#443946</link>
      <author>AHMET ANIL DINDAR</author>
      <description>Dear Rodney,&lt;br&gt;
What you adviced me was what I exactly I was looking for.&lt;br&gt;
&lt;br&gt;
Thank you for your help.&lt;br&gt;
&lt;br&gt;
greetings from Istanbul.&lt;br&gt;
&lt;br&gt;
aad&lt;br&gt;
&lt;br&gt;
%%% try-catch example %%%&lt;br&gt;
the example code&lt;br&gt;
clc,clear,close all&lt;br&gt;
a=1:1:10;&lt;br&gt;
try&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;counter=1;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;for i=1:length(a)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ali(counter,1)=a(i,1);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;counter=counter+1;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;end&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;plot(ali)&lt;br&gt;
catch&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;adem=lasterror ;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;disp(adem.message)&lt;br&gt;
end&lt;br&gt;
%%% thanks rodney %%%</description>
    </item>
  </channel>
</rss>

