Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Need help making a start/stop script... Post 302365013 by phpfreak on Sunday 25th of October 2009 08:28:23 AM
Old 10-25-2009
Bug

This is what i've got so far..

Code:
#!/bin/sh
  
  case "$1" in
    start)
	while : ; do
            ./pager.sh &&
            sleep 30
            ./pager99.sh &&

                if [ -f "pagemod.txt" ]
                then
                    :
                else
                    echo "The pagemod text was not generated during loop!"
                fi
                if [ -f "pagemod0.txt" ]
                then
                    :
                else
                    echo "The pagemod0 text was not generated during loop!"
                fi
				#COMPARE TXTS AND DETERMINE ACTION
				A=`cat pagemod.txt | head -1`                                                                        
				B=`cat pagemod.txt | head -2 | tail -1`                                                        
				C=`cat pagemod.txt | head -3 | tail -1`                                                                
				D=`cat pagemod0.txt | head -1`                                                                
				E=`cat pagemod0.txt | head -2 | tail -1`                                                        
				F=`cat pagemod0.txt | head -3 | tail -1`                                                        
				if                                                                                
					test $D -eq $A                                                                                        
					test $E -eq $B                                                                                        
					test $F -eq $C                                                                                        
				then                                        
					:                                                
				else    
					cp page0.html page0BAK.html
					cp page99.html page99BAK.html
					cp pagemod.txt pagemodBAK.txt
					cp pagemod0.txt pagemod0BAK.txt
					echo 	"Pager Report
							unimportant texts and links" >pageralert
					mail -s "Alert! Pager Report" pager <pageralert                                           
				fi 
			done
        ;;
    stop)
                #TBD/Pending conversion using wrapper
        ;;
    status)
                echo "Currently running under the following pid:
                #`ps | grep $SOME_PID | grep -v grep | cut -c 1-5`
                "
        ;;
    *)
        echo "Usage: $0 {start|stop|status}"
        exit 1
        ;;
esac

As far as using relative paths you make a point but i don't intend on moving them besides i want them to break if they do get copied elsewhere. As far as the background process issue, I do want them to complete so I added the extra but I would like to see an example of the wait command. I don't think i've ever used that yet. With the extra & I wonder if the script will run slower although speed is not of the utmost importance. Converted the idles. At first you lost me with the wrapper idea but i think i get it.. is it if I contain the loop, then for stopping the process it'll make it easier for the parent script?


*yaaaawwnnnss
BBSTSP
 

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Start/Stop Script

I'm a newbie to the Unix world Help! I have to maintain a host of Sybase database servers sitting on Unix Sun Solaris 8...I've been tasked with finding/creating a way to auto start/stop Unix via unix commands, specifically when the Unix servers need to be restarted we want Sybase to start... (2 Replies)
Discussion started by: jjv1
2 Replies

2. UNIX for Dummies Questions & Answers

Making a Script to Start as a Service

Hi, I have a shell script t1.sh. on my solaris box. So, what are the steps required to make this script run as a Service, when the system re-starts. (for ex:- at run level 3). I know that I should use the rc.d folders. But I don't know the exact steps. Kindly explain, Thanks in... (3 Replies)
Discussion started by: S.Vishwanath
3 Replies

3. Shell Programming and Scripting

Start Stop Restart

I'm wondering how I should make a script that can start, stop, and restart another script. What I need to be able to do, is start and stop a perl script from the command line. The easiest way of doing this seems to be to have another script, starting and stopping the other script. I have BASH,... (7 Replies)
Discussion started by: Bakes
7 Replies

4. Shell Programming and Scripting

Help with stop/start Shell Script.

Hi All, I would like to develop a shell script for stop & start an application server (1-4) on Solaris box. Here are the user requirements for this task. 1. User will input the option which server they wish to stop. 2. Will clear cache files from specific location. 3. ... (1 Reply)
Discussion started by: venga
1 Replies

5. UNIX for Dummies Questions & Answers

Why does fibonacci sequence script stop making sense at 92nd iteration?

So, Just for practice, I wrote a simple fibonacci sequence script in bash. (03:08:02\$ cat fib #!/usr/bin/bash ret () { echo -ne "\n" sleep .5 } a=1 b=2 echo -n $a #1 A ret echo -n $b #2 B ret (8 Replies)
Discussion started by: DeCoTwc
8 Replies

6. Solaris

Stop/start script problem on Solaris-10

I have Big brother script, which start/stop Big Brother processes. Something got change on server and now I am not able to start/stop it. There is no change in script, as I compared it from other server. This service is being managed by bb user (group is also bb). root@tsazdq04:/#... (6 Replies)
Discussion started by: solaris_1977
6 Replies

7. Shell Programming and Scripting

Shell Script for Websphere MQ Queue Manager start/stop

Hello All, I am completely new to shell scripting. I had to write a script that starts and stop the queue manager in Websphere MQ. We are on Linux 64-bit patform. The script should stop the queue manager and all the processes related to websphere MQ. It should be a clean stop. Once the queue... (3 Replies)
Discussion started by: pady1224
3 Replies

8. Shell Programming and Scripting

Shell script to stop and start server

Hi, I need to create a shell script for automated server patching, with the following scenario: I have two Linux servers Primary and secondary. Server patching should start on Primary 1st and then secondary. 1st check both servers are up and running. Then stop primary and patching will... (1 Reply)
Discussion started by: rcroyal88
1 Replies
NPM-RUN-SCRIPT(1)                                                                                                                NPM-RUN-SCRIPT(1)

NAME
npm-run-script - Run arbitrary package scripts SYNOPSIS
npm run-script <command> [--silent] [-- <args>...] alias: npm run DESCRIPTION
This runs an arbitrary command from a package's "scripts" object. If no "command" is provided, it will list the available scripts. run[-script] is used by the test, start, restart, and stop commands, but can be called directly, as well. When the scripts in the package are printed out, they're separated into lifecycle (test, start, restart) and directly-run scripts. As of ` https://blog.npmjs.org/post/98131109725/npm-2-0-0, you can use custom arguments when executing scripts. The special option -- is used by getopt https://goo.gl/KxMmtG to delimit the end of the options. npm will pass all the arguments after the -- directly to your script: npm run test -- --grep="pattern" The arguments will only be passed to the script specified after npm run and not to any pre or post script. The env script is a special built-in command that can be used to list environment variables that will be available to the script at run- time. If an "env" command is defined in your package, it will take precedence over the built-in. In addition to the shell's pre-existing PATH, npm run adds node_modules/.bin to the PATH provided to scripts. Any binaries provided by locally-installed dependencies can be used without the node_modules/.bin prefix. For example, if there is a devDependency on tap in your package, you should write: "scripts": {"test": "tap test/*.js"} instead of "scripts": {"test": "node_modules/.bin/tap test/*.js"} to run your tests. The actual shell your script is run within is platform dependent. By default, on Unix-like systems it is the /bin/sh command, on Windows it is the cmd.exe. The actual shell referred to by /bin/sh also depends on the system. As of ` https://github.com/npm/npm/releases/tag/v5.1.0 you can customize the shell with the script-shell configuration. Scripts are run from the root of the module, regardless of what your current working directory is when you call npm run. If you want your script to use different behavior based on what subdirectory you're in, you can use the INIT_CWD environment variable, which holds the full path you were in when you ran npm run. npm run sets the NODE environment variable to the node executable with which npm is executed. Also, if the --scripts-prepend-node-path is passed, the directory within which node resides is added to the PATH. If --scripts-prepend-node-path=auto is passed (which has been the default in npm v3), this is only performed when that node executable is not found in the PATH. If you try to run a script without having a node_modules directory and it fails, you will be given a warning to run npm install, just in case you've forgotten. You can use the --silent flag to prevent showing npm ERR! output on error. You can use the --if-present flag to avoid exiting with a non-zero exit code when the script is undefined. This lets you run potentially undefined scripts without breaking the execution chain. SEE ALSO
o npm help 7 scripts o npm help test o npm help start o npm help restart o npm help stop o npm help 7 config January 2019 NPM-RUN-SCRIPT(1)
All times are GMT -4. The time now is 04:37 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy