Thread Subject: publish function - Running matlab using crontab in Linux?

Subject: publish function - Running matlab using crontab in Linux?

From: Kristen Lessel

Date: 26 Jun, 2008 18:43:06

Message: 1 of 10

Hello,

I am using linux and have been attempting to set matlab up
to automatically execute my code every few hours using
crontab on Linux. I am currently using the 'publish'
function to capture the graph that is outputted in html
form. However, when using crontab, since there is no
display selected, matlab gives a warning on startup in the
command prompt:

Warning: No display specified. You will not be able to
display graphics on the screen.
Warning: No window system found. Java option 'MWT' ignored

And subsequently errors:

Error using ==> print at 310
Error using ==> prepareui at 56
Printing of uicontrols is not supported on this platform.
Error in ==> print at 310
    throw(ex);

Error in ==> snapnow>snapFigure at 349
        print(f,printOptions{:},imgFileName);

Error in ==> snapnow>leavingCell at 106
    snapFigure( ...

Error in ==> snapnow at 61
    data = leavingCell(iCell,data);

Does anyone know any way around this? I've tried messing
with a few of the different publish options.. but so far
none of them have worked. Does anyone know a way around
this? Or if there is another way to automate capturing
figure output? Please help! Thank you!!

Subject: publish function - Running matlab using crontab in Linux?

From: Scott Burnside

Date: 26 Jun, 2008 19:14:02

Message: 2 of 10

"Kristen Lessel" <drangelpsyche@yahoo.com> wrote in
message <g40nvq$96h$1@fred.mathworks.com>...
> Hello,
>
> I am using linux and have been attempting to set matlab
up
> to automatically execute my code every few hours using
> crontab on Linux. I am currently using the 'publish'
> function to capture the graph that is outputted in html
> form. However, when using crontab, since there is no
> display selected, matlab gives a warning on startup in
the
> command prompt:
>
> Warning: No display specified. You will not be able to
> display graphics on the screen.
> Warning: No window system found. Java option 'MWT'
ignored
>
> And subsequently errors:
>
> Error using ==> print at 310
> Error using ==> prepareui at 56
> Printing of uicontrols is not supported on this platform.
> Error in ==> print at 310
> throw(ex);
>
> Error in ==> snapnow>snapFigure at 349
> print(f,printOptions{:},imgFileName);
>
> Error in ==> snapnow>leavingCell at 106
> snapFigure( ...
>
> Error in ==> snapnow at 61
> data = leavingCell(iCell,data);
>
> Does anyone know any way around this? I've tried messing
> with a few of the different publish options.. but so far
> none of them have worked. Does anyone know a way around
> this? Or if there is another way to automate capturing
> figure output? Please help! Thank you!!
>
Kristen,

You could take a look at getframe (a built-in wrapper for
capturescreen.dll). You could save the frames off to a
file etc.

hth,
Scott

Subject: publish function - Running matlab using crontab in Linux?

From: Kristen Lessel

Date: 26 Jun, 2008 20:10:22

Message: 3 of 10


> Kristen,
>
> You could take a look at getframe (a built-in wrapper for
> capturescreen.dll). You could save the frames off to a
> file etc.
>
> hth,
> Scott


Hi Scott,

I did actually try that, but to no avail. I set

options.figureSnapMethod = 'getframe'

the error message that I then get is different.. but still
an error message nonetheless:

Error using ==> imwrite at 370
Image data can not be empty.

Error in ==> imwrite at 370
    error('MATLAB:imwrite:emptyImage', 'Image data can not
be empty.');

Error in ==> snapnow>writeImage at 443
    imwrite(x,imgFileName,imageType);

Error in ==> snapnow>snapFigure at 296
       
writeImage(imgFileName,imageType,myFrame,imHeight,imWidth);

Error in ==> snapnow>leavingCell at 106
    snapFigure( ...

Error in ==> snapnow at 61
    data = leavingCell(iCell,data);


Am I doing this wrong? Or is there perhaps another way?
Thanks again!

Subject: publish function - Running matlab using crontab in Linux?

From: Matthew Simoneau

Date: 26 Jun, 2008 20:17:03

Message: 4 of 10

To render user interface stuff like buttons, MATLAB needs a
display. PRINT uses something like GETFRAME to capture
these, that is, it needs a screen to snap. Maybe it's
possible to set up some sort of hidden display on Linux, but
that's my only idea.

Subject: publish function - Running matlab using crontab in Linux?

From: Scott Burnside

Date: 26 Jun, 2008 20:23:02

Message: 5 of 10

"Kristen Lessel" <drangelpsyche@yahoo.com> wrote in
message <g40t3e$bmr$1@fred.mathworks.com>...
>
> > Kristen,
> >
> > You could take a look at getframe (a built-in wrapper
for
> > capturescreen.dll). You could save the frames off to a
> > file etc.
> >
> > hth,
> > Scott
>
>
> Hi Scott,
>
> I did actually try that, but to no avail. I set
>
> options.figureSnapMethod = 'getframe'
>
> the error message that I then get is different.. but
still
> an error message nonetheless:
>
> Error using ==> imwrite at 370
> Image data can not be empty.
>
> Error in ==> imwrite at 370
> error('MATLAB:imwrite:emptyImage', 'Image data can
not
> be empty.');
>
> Error in ==> snapnow>writeImage at 443
> imwrite(x,imgFileName,imageType);
>
> Error in ==> snapnow>snapFigure at 296
>
> writeImage
(imgFileName,imageType,myFrame,imHeight,imWidth);
>
> Error in ==> snapnow>leavingCell at 106
> snapFigure( ...
>
> Error in ==> snapnow at 61
> data = leavingCell(iCell,data);
>
>
> Am I doing this wrong? Or is there perhaps another way?
> Thanks again!

You might need to use getframe(gcf). Getframe produces a
structured output. Take a look at the documentation to see
if its going to work for your purpose.

Scott

Subject: publish function - Running matlab using crontab in Linux?

From: Kristen Lessel

Date: 26 Jun, 2008 20:31:02

Message: 6 of 10

"Matthew Simoneau" <matthew@mathworks.com> wrote in message
<g40tfv$g04$1@fred.mathworks.com>...
> To render user interface stuff like buttons, MATLAB needs a
> display. PRINT uses something like GETFRAME to capture
> these, that is, it needs a screen to snap. Maybe it's
> possible to set up some sort of hidden display on Linux, but
> that's my only idea.


Is there any other way to automatically save a figure in matlab?

Subject: publish function - Running matlab using crontab in Linux?

From: Scott Burnside

Date: 26 Jun, 2008 20:48:02

Message: 7 of 10

"Kristen Lessel" <drangelpsyche@yahoo.com> wrote in
message <g40ua6$pnk$1@fred.mathworks.com>...
> "Matthew Simoneau" <matthew@mathworks.com> wrote in
message
> <g40tfv$g04$1@fred.mathworks.com>...
> > To render user interface stuff like buttons, MATLAB
needs a
> > display. PRINT uses something like GETFRAME to capture
> > these, that is, it needs a screen to snap. Maybe it's
> > possible to set up some sort of hidden display on
Linux, but
> > that's my only idea.
>
>
> Is there any other way to automatically save a figure in
matlab?

Kristen, you can save the figures directly. Take a look at
hgsave and hgload.


Scott

Subject: publish function - Running matlab using crontab in Linux?

From: Kristen Lessel

Date: 26 Jun, 2008 22:46:02

Message: 8 of 10


>
> Kristen, you can save the figures directly. Take a look at
> hgsave and hgload.
>
>
> Scott

Unfortunately that only saves .fig files... i need to be
able to put these on the web... and in any case.. crontab
will still have issues with this as again.. it needs a
display.. Thanks for your help though

Subject: publish function - Running matlab using crontab in Linux?

From: Scott Burnside

Date: 26 Jun, 2008 23:28:01

Message: 9 of 10

"Kristen Lessel" <drangelpsyche@yahoo.com> wrote in
message <g41679$rth$1@fred.mathworks.com>...
>
> >
> > Kristen, you can save the figures directly. Take a
look at
> > hgsave and hgload.
> >
> >
> > Scott
>
> Unfortunately that only saves .fig files... i need to be
> able to put these on the web... and in any case.. crontab
> will still have issues with this as again.. it needs a
> display.. Thanks for your help though

Sorry I was not helpful. Don't give up, though. Somebody
smarter will come along and respond to this thread.

Scott

Subject: publish function - Running matlab using crontab in Linux?

From: John Dunlap

Date: 12 Aug, 2009 00:20:18

Message: 10 of 10

"Scott Burnside" <no@spam.com> wrote in message <g418m1$83c$1@fred.mathworks.com>...
> "Kristen Lessel" <drangelpsyche@yahoo.com> wrote in
> message <g41679$rth$1@fred.mathworks.com>...
> >
> > >
> > > Kristen, you can save the figures directly. Take a
> look at
> > > hgsave and hgload.
> > >
> > >
> > > Scott
> >
> > Unfortunately that only saves .fig files... i need to be
> > able to put these on the web... and in any case.. crontab
> > will still have issues with this as again.. it needs a
> > display.. Thanks for your help though
>
see: http://en.wikipedia.org/wiki/Xvfb> Sorry I was not helpful. Don't give up, though. Somebody
> smarter will come along and respond to this thread.
>
> Scott

To make automatic web pages I run Matlab in VNC. My scripts loop using pause(60) until "now" returns the desired time or until an input file is updated (I use the date element returned from "dir").

In cron try making a dummy DISPLAY using xvfb, a virtual frame buffer for X windows.
see: http://en.wikipedia.org/wiki/Xvfb
You can try starting with "matlab -nosplash -nojvm".

Regards,
John

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
uicontrol Matthew Simoneau 26 Jun, 2008 16:20:06
display Matthew Simoneau 26 Jun, 2008 16:20:06
print Matthew Simoneau 26 Jun, 2008 16:20:06
publish Matthew Simoneau 26 Jun, 2008 16:20:06
publish Kristen Lessel 26 Jun, 2008 14:45:14
crontab Kristen Lessel 26 Jun, 2008 14:45:14
linux Kristen Lessel 26 Jun, 2008 14:45:14
rssFeed for this Thread

Contact us at files@mathworks.com