LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-31-2008, 03:39 AM   #1
maradnus
Member
 
Registered: Oct 2008
Location: Yellagiri Hills
Distribution: Fedora
Posts: 87

Rep: Reputation: 15
Question How to display a message box through a background script?


[Log in to get rid of this advertisement]
Dear all,

I wrote a program in C language which has to
display a message box on the screen (in X windows).

I used the following code
Code:

system("kdialog --mesgbox \" Some Message text\"");

I works well When I run it in the background manually on the console
but It doesn't work When I put it in /etc/rc.local file.

/etc/rc.local contains the following line:

Code:

/usr/local/bin/myprogram &

The above program gets executed but the dialog doesn't appear.


Please give me some idea...

Thanks
 
Old 10-31-2008, 05:26 AM   #2
SciYro
Senior Member
 
Registered: Oct 2003
Location: hopefully not here
Distribution: Gentoo
Posts: 2,038

Rep: Reputation: 51
Whats the error output say? It could be that kdialog is unable to run due to lack of a running X server, or is unable to find the server, or possibly other conditions of its starting.
 
Old 10-31-2008, 08:29 AM   #3
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
SciYro is correct. When rc.local runs at boot time, there is no locally running X server upon which to display the output. You could set up a remote X server that will accept connections over the net, and then set $DISPLAY in rc.local to point to the X server. Or, if you don't actually need to see the output dialog, you could run a virtual X server like Xvfb, which will allow the application to run, albeit invisibly. Dialog boxes usually require user interaction in order to carry on, which usually makes them unsuitable for use in the boot process.
--- rod.
 
Old 10-31-2008, 09:17 AM   #4
maradnus
Member
 
Registered: Oct 2008
Location: Yellagiri Hills
Distribution: Fedora
Posts: 87

Original Poster
Rep: Reputation: 15
Dear members,

Thanks for your valuable replies..

The program is started while booting but will run continuously for
every five minutes in the background.

The particular code snippet will be executed while the
user is working with some applications on the desktop...


thanks
 
Old 10-31-2008, 09:31 AM   #5
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
I have managed a similar situation, where I want a perpetually running application that also has an interactive console to be launched at boot time, on a headless machine. I accomplished this by running Xvfb, which can then host an xterm that hosts a Gnu screen session, running in multi-user mode. In rc.local, I use screen's 'stuff' command to start my application, which then runs. All of this is done in rc.local.
Later, from anywhere, I can attach to the screen session to monitor and interact with the application. Multiple users can do this, concurrently. Its a monumental hack, but it works.
--- rod.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to display a message box through a background script? maradnus Linux - Newbie 5 10-31-2008 10:57 AM
Bash script hangs upon starting another script in the background masea2 Linux - Software 4 11-13-2006 05:18 AM
Background Message jake2 Fedora 1 07-10-2006 02:44 AM
Password Message Box when accessing linux box from Window Machine mikeccs Linux - Networking 1 08-04-2004 05:47 AM
how to produce pop-up message box / alert window from shell script peb Linux - Newbie 3 02-25-2004 03:14 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:31 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration