I copied and pasted the "/etc/init.d/skeleton" file to a new one so I could create my own init script for a program.
Basically the ONLY edit I made to the skeleton "template" so far was to search and replace "FOO" with "snort".
*NOTE: I know there are a bunch of snort init scripts out there, but they weren't working the way I wanted, so I wanted to play around a bit with the init script because I had just recently found out what the 'skeleton' file was for...
But anyway, when I run the script with 'status' as the only argument to the script it seems to execute the init script twice. i.e. It prints out the status twice to the screen...
Like this: And if I change the line in the script for status from: To This:
I get this as the output, which is telling me it's executing twice for some reason...
Any idea why this would execute twice? Below is the skeleton file, I removed MOST of the comment lines because there are a TON... Filename: snort_skeleton Command--> /etc/init.d/snort_skeleton status
If anyone has ANY ideas why this would be happening please feel free...
Any thoughts or suggestions would be greatly appreciated.
Thanks in Advance,
Matt
--------------------------------------------------------------------------------------------------------------------------------------------------- UPDATE: I added a simple echo statement to the very start of the script on the 1st line after the shebang line: echo "FIRST LINE:"
Then, I run the script again manually from the command line, with: ./snort_skeleton status
And the Output is:
Just thought that was VERY strange... Any ideas??
Thanks Again,
Matt
---------- Post updated at 04:34 PM ---------- Previous update was at 02:24 PM ----------
Sorry, didn't want to just keep Update/Editing my original post, but I just found something else that seems pretty strange...
If I execute the script and I include a 2nd argument on the cli, NO MATTER WHAT THE ARG IS, it only runs once. I can make the
2nd argument be anything. From another init option like, start|stop|restart|etc... to "foo" to a single number, it ONLY runs once... How
strange is that??
Example: But if I include "status" as the ONLY option I get:
Thought that could possibly help. I do see in the script they use "$@" but that is the only reference I see to more then just the 1st
CLI Option, *i.e. "$2" is not used in the script anywhere...
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:
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: So if I added the echo commands like in the code above, I now get:
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.
I see a couple of default for statments in there. Like this:
That "for i" is going to loop over all of the positional parameters. You are on the right track using echo statement to figure out where it loops. I would continue with that in rc.status. However... rc.status is possibly in use by other scripts so make a temparary copy and change your parent script to invoke the temporary copy. Then add echo statements to your temporary copy to shed more light. I would be generous with my echo statements in the vicinity of those "for" statements I mentioned. Those are loops that will behave differently when you supply a superfluous argument.
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)
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)
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)
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
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)
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,
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)
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)
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)
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)