Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm working on a Windows 7 machine, having a VM for Ubuntu (image disk: 12.04-desktop-i386.iso).

On the VM I installed Monit 5.3.2, and configured some processes and applications. So I created a script to run my application. This application should display some content on the screen (Im basically displaying two images, using Feh).

The thing is: if I call my script through the command line, it runs ok, and display the images. But if I run through monit, it seems to be running ok, but it doesn't display the images.In the case I try to debug it (remote debug), then I can see the images. So I was supposing this could be some kind of configuration, but didn't find out what (even using the option -I wou'ldn't work).

I"m showing below more details:

-Piece of script on Monit----

check program runMediaHandler with path "/usr/bin/runMediaHandler.sh"
 if status == 1 then alert

-runMediaHandler.sh ----

#!/bin/bash
java -jar /home/thais/Desktop/MediaHandler_RC2.jar

Summarizing:

1.What works:

  • if I run java directly: java -jar /home/thais/Desktop/MediaHandler_RC2.jar

  • if I run the script directly: runMediaHandler.sh

  • if I remote debug putting a breakpoint where the image should be displayed

2.What does not work:

  • putting that piece of information on Monit to "check program", writen above (even if calling monit -I start runMediaHandler)

I'm strongly believing it's related to some background issue, otherwise, why it would display the picture using remote debug?

Thank you in advance,

Thaís

share|improve this question
add comment

1 Answer 1

I'm just posting how I did to solve it in case someday someone needs a similar help...

In the end I tried a few steps that made my program work

  1. Not sure if necessary, but I executed the command line (according to monit manual) to make monit run on the foreground:

    /usr/bin/monit -Ic /etc/monit/monitrc
    
  2. I changed my script to set a display and to execute with my user. See how it's now:

    #!/bin/bash    
    export DISPLAY=:0.0
    su -c "java -jar /home/thais/Desktop/MediaHandler_RC2.jar" thais
    
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.