Help - Search - Members - Calendar
Full Version: File Formats
Linuxhelp > Support > Technical Support
MaverickApollo
I have a rc script that wont run, and I think (I know) it is in the wrong format, PC formatted not unix formatted, so it is'nt working. Can any one tell me how I can check the formatting and change it?

Many Thnaks

Michael.
MaverickApollo
Also, I have another script that runs fine when I have typed its' name on the command line such as

/etc/rc.d/init.d/scriptname start

This starts it fine without problems. Doing tail /var/log/messages does not show any errors.
I have set it to start at boot up, but it dosnt run. I need to enter the script name manually before it runs.

If I do a chkconfig --list it shows it is registered in run levels 2345, which is where it should be. It is scheduled to start on system boot by doing

/usr/sbin/setup and going to system setup, and setting it there. I have also checked in the RH9 GUI version of the system startup util.

Anyone got any ideas?
hughesjr
As to the scripts that run when typed from the command line and not on startup, the most common cause is that you need to either set the PATH in the script or include the full pathname to all executables ..(ie /bin/grep instead of just grep) ... when you type something from the command line, the environment for root is setup, but when running at startup that is not necessarily the case.

The easy thing to do is to include the following statement in all startup scripts:

PATH=/sbin:/bin:/usr/bin:/usr/sbin:/usr/local/bin
----------------------------------
As to the formating ... I think you mean that there are dos CRLF's at the end of the lines in the file...how you can see if this is the case is to open the file with gedit ... it will show a ^M or ^P at the end of the lines if they are wrong.

I use notetab light to save text files in UNIX format if I am going to move them from a dos machine to a Unix machine ... in notetab go to the menu selection Document then select Properties then choose UNIX in the Format dropdown box.

You can use notetab light to same your current dos text file in UNIX text mode...
MaverickApollo
The full path is specified in the script.

I'll try adding the path variables

Heres a copy of the script:

#!/bin/bash
#
# Script to run Fetchmail software at boot time.
#
# Last Updated: 31st August 2003
#
# This script is based upon the init scripts
# as used on Red Hat Linux.
#
# The script has been tested on RH 7.x, 8.0, and 9.0
#
# Author: Gary Myers AMBCS
# mailto: gary@gaztronics.co.uk
#
# This script is realeased under the terms of the GPL.
# You can source a copy at:
# http://www.fsf.org/copyleft/copyleft.html

#====================================================================
# Run level information
#
# chkconfig: 2345 99 90
# description: Fetchmail
#
# Run "/sbin/chkconfig --add seti" to add the Run levels;
# this *should* setup the symlinks!
#====================================================================

PATH=/sbin:/bin:/usr/bin:/usr/sbin:/usr/local/bin
#====================================================================
# Set the path to the executable.
#
FETCHMAIL=/usr/bin/fetchmail

# Set the path to the runtime control file.
#
FRC=/root/.fetchmailrc

# Path to the lock file.
#
LOCK_FILE=/var/lock/subsys/fetchmail

# Set this time for daemon operations.
# Default for this config is 1 hour.
#
TIME=200

#====================================================================

#====================================================================

# System checks:

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

# Check that networking is up.
# No point in trying to send or recieve otherwise!!
[ ${NETWORKING} ="yes" ] || exit 0

# Check we have the fetchmail program installed.
if [ ! -x $FETCHMAIL ] ; then
echo "Cannot find Fetchmail executable!"
exit 0
fi

# Check the .fetchmailrc file exists - fetchmail doesn't run
# in daemon mode without it.

if [ ! -f $FRC ] ; then
echo "Cannot find the runtime control file!"
exit 0
fi

#====================================================================

prog=$"Fetchmail"

RETVAL=0

start() {
if [ -f $LOCK_FILE ]; then
echo "Fetchmail is already running!"
exit 0

else

echo -n $"Starting $prog: "
$FETCHMAIL --daemon $TIME >/dev/null 2>&1
fi

RETVAL=$?
[ $RETVAL -eq 0 ] && success
echo
[ $RETVAL -eq 0 ] && touch $LOCK_FILE
return $RETVAL
}

stop() {
echo -n $"Shutting down $prog: "
killproc fetchmail
RETVAL=$?
[ $RETVAL -eq 0 ]
rm -f $LOCK_FILE
echo
return $RETVAL
}

# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
condrestart)
if [ -f $LOCK_FILE ]; then
stop
start
RETVAL=$?
fi
;;
status)
status fetchmail
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|restart|condrestart|status}"
RETVAL=1
esac

exit $RETVAL
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2017 Invision Power Services, Inc.