I apologize, the script that had the "$@" was the "skeleton.compat" file, not the file called just skeleton. Which is what
I'm using.
But even so, without the $@, it is still looking as though it is executing twice. I thought it was very strange that if you include a
second command line option, it only prints the output once.
But, you'd think if it was simply executing twice, that it would write MY output line then the status. Then again in the same output
my output again then the status. Not both of my output lines then both of the status lines, which is what it is doing now.
For Example: If I added the line "echo 'Hello' " to the start of the script... It prints:
Code:
Hello
Hello
Checking for service snort Not Running
Checking for service snort Not Running
Strange...
Thanks again for the reply.
Thanks,
Matt
---------- Post updated at 04:25 PM ---------- Previous update was at 11:00 AM ----------
Ok, so I added some more echo lines to the script in different locations just to see how it would print out, and if I could see
where it was beginning to execute all over again, and I got some interesting output...
If I add the "echo(s)" like in the code below:
Code:
#!/bin/sh
echo -ne "1st ECHO:\n"
# Check for missing binaries (stale symlinks should not happen)
# *Note: Special treatment of stop for LSB conformance
snort_BIN=/usr/sbin/snort
test -x $snort_BIN || { echo "$snort_BIN not installed";
if [ "$1" = "stop" ]
then
exit 0
else
exit 5
fi; }
echo -ne " 2nd ECHO:\n"
# Check for existence of needed config file and read it
snort_CONFIG=/etc/sysconfig/snort
test -r $snort_CONFIG || { echo "$snort_CONFIG not existing";
if [ "$1" = "stop" ]
then
exit 0
else
exit 6
fi; }
echo -ne " 3rd ECHO:\n"
# Read config
. $snort_CONFIG
echo -ne " 4th ECHO:\n"
. /etc/rc.status
echo -ne " 5th ECHO:\n"
# Reset status of this service
rc_reset
echo -ne " 6th ECHO:\n"
case "$1" in
start)
echo -ne " 7th ECHO in 'START)':\n"
echo -n "Starting snort "
## Start daemon with startproc(8). If this fails
## the return value is set appropriately by startproc.
/sbin/startproc $snort_BIN
# Remember status and be verbose
rc_status -v
;;
stop)
echo -ne " 7th ECHO in 'STOP)':\n"
echo -n "Shutting down snort "
## Stop daemon with killproc(8) and if this fails
## killproc sets the return value according to LSB.
/sbin/killproc $snort_BIN
# Remember status and be verbose
rc_status -v
;;
try-restart|condrestart)
echo -ne " 7th ECHO in 'TRY-RESTART|CONDRESTART)':\n"
if test "$1" = "condrestart"; then
echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}"
fi
$0 status
if test $? = 0; then
$0 restart
else
rc_reset # Not running is not a failure.
fi
# Remember status and be quiet
rc_status
;;
restart)
echo -ne " 7th ECHO in 'RESTART)':\n"
## Stop the service and regardless of whether it was
## running or not, start it again.
$0 stop
$0 start
# Remember status and be quiet
rc_status
;;
force-reload)
echo -ne " 7th ECHO in 'FORCE-RELOAD)':\n"
echo -n "Reload service snort "
## if it supports it:
/sbin/killproc -HUP $snort_BIN
#touch /var/run/snort.pid
rc_status -v
;;
reload)
echo -ne " 7th ECHO in 'RELOAD)':\n"
# If it supports signaling:
echo -n "Reload service snort "
/sbin/killproc -HUP $snort_BIN
rc_status -v
;;
status)
echo -ne " 7th ECHO in 'STATUS)':\n"
echo -n "Checking for service snort "
appl.)
# NOTE: checkproc returns LSB compliant status values.
/sbin/checkproc $snort_BIN
# NOTE: rc_status knows that we called this init script with
# "status" option and adapts its messages accordingly.
rc_status -v
;;
probe)
echo -ne " 7th ECHO in 'PROBE)':\n"
## Optional: Probe for the necessity of a reload, print out the
## argument to this init script which is required for a reload.
## Note: probe is not (yet) part of LSB (as of 1.9)
test /etc/snort/snort.conf -nt /var/run/snort.pid && echo reload
;;
*)
echo -ne " 7th ECHO in '*)':\n"
echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"
exit 1
;;
esac
rc_exit
So if I added the echo commands like in the code above, I now get:
Code:
snortIDS:/etc/init.d # ./snort_skeleton status
1st LINE:
2nd LINE:
3rd LINE:
4th LINE:
1st LINE:
2nd LINE:
3rd LINE:
4th LINE:
5th LINE:
6th LINE:
7th LINE in 'STATUS)':
Checking for service snort Not Running
5th LINE:
6th LINE:
7th LINE in 'STATUS)':
Checking for service snort Not Running
############################################################
snortIDS:/etc/init.d # ./snort_skeleton status
1st LINE:
2nd LINE:
3rd LINE:
4th LINE:
5th LINE:
6th LINE:
7th LINE in '*)':
Usage: ./snort_skeleton {start|stop|status|try-restart|restart|force-reload|reload|probe}
############################################################
snortIDS:/etc/init.d # ./snort_skeleton status 1
1st LINE:
2nd LINE:
3rd LINE:
4th LINE:
5th LINE:
6th LINE:
7th LINE in 'STATUS)':
Checking for service snort Not Running
As you can see from the 3 different commands I issued I get different output each time... It seems like right about where I am
sourcing the ". /etc/rc.status" file is where it is starting to repeat... Weird.
Hi Expert,
I have encountered some problem with my SUN system. Everytime when i issue command #init 6 OR #init 0 it just logout and prompt for login again instead of rebooting the server when run init 6 and system shutdown when run init 0..
I can only reboot the system using reboot ... Was... (6 Replies)
Dear all
I would like to capture who executed a script to a script's variable (i.e. testing.sh), so I can save it to a log file.
testing.sh
#! bin/ksh
user=`<< code here >>` // get the info below in RED color
<<main logic>>
echo "$user execute testing.sh on `date`" >> testing.log
... (2 Replies)
Dear all,
I typed in init 1 on my redhat box as root and according to wikipedia (http://en.wikipedia.org/wiki/Runlevel):
1 Single-User Mode Does not configure network interfaces, start daemons, or allow non-root logins
So now I can't connect back to it. How do I change the init back to 3?... (8 Replies)
Hi,
I am experiencing a weird thing on my SUNFIRE machine with Solaris 9 OS.
When I do init 0 to shutdown the machine to go to ok prompt, what it did was shutdown and reboot like an init 6 command do. I did check the corresponding rc scripts that were involved with init 0 and compared with rc... (2 Replies)
I encountered a problem on one of our database servers.
OS: CentOS 5.5 final
Kernel: 2.6.18-238.5.1.el5.028stab085.2 (OpenVZ kernel)
We wrote some DB-Start/Stop-scripts ("/db2/admin/scripts_dba/start_services.ksh" and ".../stop_services.ksh") to start the database instances. (Database... (1 Reply)
Hi
Script not getting executed via cron but executes successfully when executed manually. Please assist
cbspsap01(appuser) /app/scripts > cat restart.sh
#!/bin/ksh
cd /app/bin
date >>logfile.out
echo "Restart has been started....." >>logfile.out
date >>logfile.out
initfnsw -y restart... (3 Replies)
Hi,
I am having a shell script which has a while loop as shown below.
while
do
sleep 60
done
I am executing this script from Informatica ETL tool command task from where we can execute UNIX commands/scripts. When i do that, i am seeing 2 processes getting started for one script... (2 Replies)
Hi All,
I'm trying to build a start up script, wud be gr8 if any one can explain what the below field means and how can i check it for my script.
DAEMON_PATH="/home/wes/Development/projects/myapp"
DAEMON=myapp
DAEMONOPTS="-my opts"
NAME=myapp
DESC="My daemon description"... (4 Replies)
I have bash shell script which is internally calling python script.I would like to know how long python is taking to execute.I am not allowed to do changes in python script.Please note i need to know execution time of python script which is getting executed inside shell .I need to store execution... (2 Replies)
This is what I did:
1. I wrote a simple init.d script (myscript.sh)
2. I placed it under /etc/init.d (where many other default scripts already are)
3. Set the perms to 755
4. Run: update-rc.d myscript.sh defaults
I can run it perfectly by doing:
/etc/init.d/myscript.sh start... (2 Replies)