Thread Subject: "program terminated" message by mail

Subject: "program terminated" message by mail

From: AHMET ANIL DINDAR

Date: 15 Jul, 2008 22:22:02

Message: 1 of 5

Hi,
I've been doing a long-hours-run analysis in MATLAB in which
I used "sendmail" in several parts of the script with the
intention of having been informed about the process. It
worked superb till now.

However, my analysis program terminates due to several
reasons. At such moment, I follow the incoming mails and
find the last action in the process. Is it possible to write
a code that runs my program and checks whether it is running
or not? And in case of termination the code sends an e-mail
message.

Any idea?

thanks in advance.

ahmet_anil_dindar

Subject: "program terminated" message by mail

From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)

Date: 15 Jul, 2008 22:34:49

Message: 2 of 5

In article <g5j7ua$s3u$1@fred.mathworks.com>,
AHMET ANIL DINDAR <adindar@iku.edu.tr> wrote:
>Is it possible to write
>a code that runs my program and checks whether it is running
>or not? And in case of termination the code sends an e-mail
>message.

Yes.

The ease of doing so will depend greatly upon which operating
system you are using, which you have not stated. It would
be automatic in Unix if you start the Matlab run using the "batch"
command.

--
  "They called it golf because all the other four letter words
  were taken." -- Walter Hagen

Subject: Re:

From: AHMET ANIL DINDAR

Date: 16 Jul, 2008 06:20:19

Message: 3 of 5

Thanks for the answer. I didn't know the OS was important
for such a program since I'm not an expert on programming.
Anyway, I'm using XP in my comp. Is there still a chance to
use the "batch" command?

thanks again.

Subject: Re:

From: Rodney Thomson

Date: 16 Jul, 2008 07:42:02

Message: 4 of 5

"AHMET ANIL DINDAR" <adindar@iku.edu.tr> wrote in message
<g5k3v3$ruc$1@fred.mathworks.com>...
> Thanks for the answer. I didn't know the OS was important
> for such a program since I'm not an expert on programming.
> Anyway, I'm using XP in my comp. Is there still a chance to
> use the "batch" command?
>
> thanks again.

One thing you could possibly do is put a try/catch block in
your mainline that encompasses all of your code. And then on
any errors you can send an email notifying the source and
reason of the error.

In the catch block you could do something like:

catch
  err = lasterror;

  error_message = sprintf('Error: %s::%s\nOccured in %s::%s
at line %d\n', err.identifier, err.message, err.stack.file,
err.stack.name, err.stack.line);

  sendmail('uhoh@itdied.com', 'Matlab process crashed',
error_message);
end

NOTE: I've not run this code so treat it as pseudocode

--
http://iheartmatlab.blogspot.com

Subject: Re:

From: AHMET ANIL DINDAR

Date: 18 Jul, 2008 15:52:02

Message: 5 of 5

Dear Rodney,
What you adviced me was what I exactly I was looking for.

Thank you for your help.

greetings from Istanbul.

aad

%%% try-catch example %%%
the example code
clc,clear,close all
a=1:1:10;
try
    counter=1;
    for i=1:length(a)
        ali(counter,1)=a(i,1);
        counter=counter+1;
    end
    plot(ali)
catch
    adem=lasterror ;
    disp(adem.message)
end
%%% thanks rodney %%%

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
example code AHMET ANIL DINDAR 18 Jul, 2008 11:55:08
trycatch AHMET ANIL DINDAR 18 Jul, 2008 11:55:08
sendmail AHMET ANIL DINDAR 15 Jul, 2008 18:25:12
warning message AHMET ANIL DINDAR 15 Jul, 2008 18:25:12
program terminate AHMET ANIL DINDAR 15 Jul, 2008 18:25:11
rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com