Fedora Linux Support Community & Resources Center
  #1  
Old 10th July 2010, 01:13 AM
ploceus Offline
Registered User
 
Join Date: Jul 2010
Posts: 2
windows_xp_2003firefox
init.d script won't show [ OK ] message.

Hi.

I have script named "foo" in /etc/rc.d/init.d so I can start/stop/restart it.

When I write
# ./foo start
Starting server a.out:

And thats it.... I do not see [ OK ] message on the right and there's no shell prompt.

a.out is a perfectly valid small sample program, so what is missing here?

On the other hand if I replace my sample program with another application, then I do see the [ ok ] message. So the foo script is correct.

It seems that I'm missing some message or signal passing mechanism in the sample program, but have no idea of what it is.

Any suggestions?
Thanks
Reply With Quote
  #2  
Old 10th July 2010, 01:39 AM
dd_wizard's Avatar
dd_wizard Offline
Registered User
 
Join Date: Sep 2009
Posts: 1,409
linuxfedorafirefox
Re: init.d script won't show [ OK ] message.

Those spiffy messages are functions that are defined in /etc/rc.d/init.d/functions. Here's an example of how I use them in /etc/rc.d/rc.local:
Code:
[gene@Mobile-PC init.d]$ cat /etc/rc.d/rc.local
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

# Run the acpi ac adapter script in case the machine booted on batteries.
# Loading the governors at boot also makes them show up in the desktop
# CPU frequency scaling monitor applet.

# Source the init.d function library.
. /etc/rc.d/init.d/functions

log_msg="Initializing AC adapter acpi action"
logger="/usr/bin/logger -t rc.local "
ACAD_acpi_action="/etc/acpi/actions/ac_adapter.sh"
RETVAL=0

echo -n "${log_msg}: "
[ -x ${ACAD_acpi_action} ] && ${ACAD_acpi_action} || RETVAL=$?
if [ ${RETVAL} -eq 0 ]
then success
    $logger "${log_msg} succeeded"
else failure
    $logger "error: ${log_msg} failed with exit code ${RETVAL}"
fi
echo

touch /var/lock/subsys/local
exit ${RETVAL}
The first highlighted section loads the functions. The second section starts the line of text in /var/log/boot.log or your terminal. The third and fourth sections (success or failure) print the [ OK ] or [ FAILED ] part of the message. The last echo prints a new line.

dd_wizard

---------- Post added at 05:39 PM CDT ---------- Previous post was at 05:28 PM CDT ----------

P.S. The logger stuff puts entries in /var/log/messages.

dd_wizard

Last edited by dd_wizard; 10th July 2010 at 01:49 AM.
Reply With Quote
  #3  
Old 10th July 2010, 02:23 AM
ploceus Offline
Registered User
 
Join Date: Jul 2010
Posts: 2
windows_xp_2003firefox
Re: init.d script won't show [ OK ] message.

dd_wizard,

Thanks for your reply. Your message helped me solve the problem. The problem was that my sample program was not daemonized. After I enabled my sample program to fork and detach from the parent process, I can see the [ OK ] being printed upon starting and restarting the foo script.

http://www-theorie.physik.unizh.ch/~...owto/daemonize

Reply With Quote
Reply

Tags
initd, message, script

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
f8 live don't start and show this message qwe010 Installation and Live Media 12 23rd February 2008 07:44 PM
squirrelmail doesn't show message content? gundark Using Fedora 0 6th May 2007 08:57 PM
Init Script Help NDog Using Fedora 2 14th February 2007 02:03 AM
init.d script rs232 Using Fedora 6 4th December 2006 01:39 AM


Current GMT-time: 09:51 (Thursday, 20-06-2013)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat