Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 10-31-2008, 02:35 AM   #1
Registered: Oct 2008
Location: Yellagiri Hills
Distribution: Fedora
Posts: 87

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

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
             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:

            /usr/local/bin/myprogram &
The above program gets executed but the dialog doesn't appear.

Please give me some idea...

Old 10-31-2008, 04:49 AM   #2
Registered: Aug 2006
Location: Vancouver, BC, Canada
Distribution: Slackware, Bodhi, Mint-xfce
Posts: 183

Rep: Reputation: 21
I am not an expert on rc.local but if I am not mistaken it is executed after the init scripts are run.
This has implications, such as you cannot assume X is running, it will probably be run with root privileges,
and be run before you have a chance to login as a user!
You might want to write to a log file or move your program so that it is executed after X is started or when a user logs in!

Have you tried running your program when booted to 'single-user mode' or one of the 'text-only modes' when X is not loaded?

What does your program do?
Old 10-31-2008, 05:10 AM   #3
LQ Newbie
Registered: Mar 2007
Location: Bangalore
Posts: 4

Rep: Reputation: 0

type msgbox instead of mesgbox, it should work.

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

Old 10-31-2008, 09:57 AM   #4
Registered: Oct 2008
Location: Yellagiri Hills
Distribution: Fedora
Posts: 87

Original Poster
Rep: Reputation: 15

Dear Roy,

Thanks for reply..

The purpose of the program is to remind the user about
the time of shutdown.

So the C program will be running in the background and checks
the system time repeatedly for every five minutes.
When the system times lies in between the specified time,
the program will show the appropriate message to the user
using kdialog and after few minutes it will shutdown the system.

The program shuts down the system exactly when somebody works
with Desktop(X and multiuser mode) but the dialog was not displayed....

Old 10-31-2008, 10:00 AM   #5
Registered: Oct 2008
Location: Yellagiri Hills
Distribution: Fedora
Posts: 87

Original Poster
Rep: Reputation: 15

Dear barunva,

Thanks for your reply.

It was a typing mistake but in the program i gave correctly.

Old 10-31-2008, 11:57 AM   #6
Registered: Apr 2008
Location: Toulon (France)
Distribution: FEDORA CORE
Posts: 493

Rep: Reputation: 50
IMHO you'd better add the line running your program into each user ".bashrc" file, and for future users into "/etc/skel/.bashrc"


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Bash script hangs upon starting another script in the background masea2 Linux - Software 4 11-13-2006 06:18 AM
Background Message jake2 Fedora 1 07-10-2006 03:44 AM
Password Message Box when accessing linux box from Window Machine mikeccs Linux - Networking 1 08-04-2004 06:47 AM
Linux box calling a batch script on a windows box to run? Is it possible? joelhop Programming 8 05-17-2004 05:49 PM
how to produce pop-up message box / alert window from shell script peb Linux - Newbie 3 02-25-2004 04:14 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:56 PM.

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