Sponsored Content
Top Forums Shell Programming and Scripting Difference between kshell and bash shell scripts Example cited Post 302791303 by ankur328 on Monday 8th of April 2013 09:11:24 AM
Old 04-08-2013
i am sorry i am bit naive into this forum..


this is inside manger.ksh

Code:
function startProcess
{
	for INSTANCE in ${CONTENT}
	do
		PROC_COUNT=`ssh ${SERVER} "ps -ef | egrep -e '-c ${INSTANCE}'| grep -v grep | wc -l"`
		
		if [[ ${PROC_COUNT} -gt 0 ]]; then
			echo "${SERVER}: ${INSTANCE} process is ACTIVE. "
		else
			ssh ${SERVER} "${CONSCRIPTS}/atg_control.sh -e ${ENV} -i ${INSTANCE} -c start" > /dev/null &
			if [[ ${?} -eq 0 ]]; then
				echo "${SERVER}: Startup initiated for ${INSTANCE}. Run checkstatus to check progress."
			else
				echo "ERROR: Problems Encountered with startup of ${INSTANCE} on ${SERVER}"
				exit 1
			fi
			
			if [[ ${WAIT} -gt 0 ]]; then
				echo "Server startup in progress..."
				while [[ ${PROC_COUNT} -gt 0 ]]
				do
					sleep 10
					PROC_COUNT=`ssh ${SERVER} "ps -ef | egrep -e '-c ${INSTANCE}'| grep -v grep | wc -l"`
				done
			fi
			
		fi
	done
}

function stopProcess
{
	for INSTANCE in ${CONTENT}
	do
		PROC_COUNT=`ssh ${SERVER} "ps -ef | egrep -e '-c ${INSTANCE}'| grep -v grep | wc -l"`
		
		if [[ ${PROC_COUNT} -gt 0 ]]; then
			ssh ${SERVER} "${CONSCRIPTS}/atg_control.sh -e ${ENV} -i ${INSTANCE} -c stop" > /dev/null &
			if [[ ${?} -eq 0 ]]; then
				echo "${SERVER}: Shutdown initiated for ${INSTANCE}. Run checkstatus to check progress."
			else
				echo "ERROR: Problems Encountered with shutdown of ${INSTANCE} on ${SERVER}"
				exit 1
			fi
			
			if [[ ${WAIT} -gt 0 ]]; then
				echo "Server shutdown in progress..."
				while [[ ${PROC_COUNT} -gt 0 ]]
				do
					sleep 10
					PROC_COUNT=`ssh ${SERVER} "ps -ef | egrep -e '-c ${INSTANCE}'| grep -v grep | wc -l"`
				done
				echo "Server shutdown complete"
			fi
		else
			echo "${SERVER}: ${INSTANCE} is already down"
		fi
	done
}

function restartProcess
{
for INSTANCE in ${CONTENT}
do

  echo "${SERVER}: Restart initiated for ${INSTANCE}"
  ssh ${SERVER} "${CONSCRIPTS}/atg_control.sh -e ${ENV} -i ${INSTANCE} -c restart" > /dev/null &
  if [[ ${?} -eq 0 ]]; then
     echo "${SERVER}: Restart initiated for ${INSTANCE}. Run checkstatus to check progress."
   else
       echo "ERROR: Problems Encountered with restart of ${INSTANCE} on ${SERVER}"
   fi

done
}

function main
{
for SERVER in ${SERVLIST}
do
  case ${ACTION} in
    stop)   stopProcess ${SERVER} ${CONTENT} ${ENV};;
    start)  startProcess ${SERVER} ${CONTENT} ${ENV};;
    restart)  restartProcess ${SERVER} ${CONTENT} ${ENV};;            
    install)  installJboss ;;
    deploy)   deployjboss ;;
    *)        usage;;
 esac
done
}











=========================================================


and i have attached control.sh:

Last edited by vbe; 04-08-2013 at 10:21 AM.. Reason: code tags
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Bash Shell Scripts

Hi all, plz can anybody tell me that if a script written for Bash shell also work for other shells and if yes , how ??? Thanks and Regards SONAL (2 Replies)
Discussion started by: sonbag_pspl
2 Replies

2. UNIX for Dummies Questions & Answers

Difference in Shell Scripts

Hi, Is anyone can help me to find out the difference in Shell Scripts between HP and Sun. Thanks in advance, Vijay R (3 Replies)
Discussion started by: rv_kumar
3 Replies

3. AIX

Difference between writing Unix Shell script and AIX Shell Scripts

Hi, Please give me the detailed Differences between writing Unix Shell script and AIX Shell Scripts. Thanks in advance..... (0 Replies)
Discussion started by: haroonec
0 Replies

4. AIX

Kshell scripts and timing

Hello everyone, I have a script thats acting funky, what I would like to do is report to a file, how long its taking to get to certain area's, in seconds. For example. -- Start timer -- Run unix command 1 -- Run unix command 2 -- Stop timer -- Report Seconds -- etc etc Is there a way... (3 Replies)
Discussion started by: dbridle
3 Replies

5. Shell Programming and Scripting

callint Kshell script from bash default shell

I am trying to set some environment variables in a shell script which is written in Kshell. I am invoking this script in .profile. The problem is envirnment variables are set within the script but after exiting the script those are gone. I don't have any problem with If I have Kshell as my default... (0 Replies)
Discussion started by: roopla
0 Replies

6. Shell Programming and Scripting

Is there any difference in bash shell in [ .. ] and [[ .. ]] ?

Could someone tell me if there is any difference in using square brackets single or doubled pair? So, do those two some how could be treted by shell differently: if ; then <statements;> else <statements;> fi and if ] ; then <statements;> else <statements;> fi Maybe any one could... (5 Replies)
Discussion started by: alex_5161
5 Replies

7. Solaris

difference in calling shell scripts

Hi I am getting some errors when i am running the shell script using the following syntax: >abc.sh but the same script works fine with the following syntax: >sh abc.sh wats the difference in both....please help thanks in advance. (6 Replies)
Discussion started by: arpit_narula
6 Replies

8. UNIX for Dummies Questions & Answers

Repetitive scripts within a bash shell

I have a bash shell that even though it does not look pretty is working very well. Some of the steps are repetitive, something like this: muscle -in ${e}.4 > $e.5 read -t1 sed ':a /^>/!N;s/\n\(\)/\1/;ta' $e.5 > $e.6 read -t2 awk '/>/{fr=$3;getline;n=split ($0,a,""); for (i=1;i<=n;i++)... (2 Replies)
Discussion started by: Xterra
2 Replies

9. Homework & Coursework Questions

Bash shell scripts

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Test that exactly one command line argrument is enter from the command line. If not, display the usage... (1 Reply)
Discussion started by: jcoop12
1 Replies

10. UNIX for Beginners Questions & Answers

Understanding the difference between individual BASH login scripts

Hello... and thanks in advance for reading this or offering me any assistance I'm trying to understand specific differences between the various login scripts... I understand the differences between interactive vs non-interactive and login vs non-login shells... and that's not where my question... (4 Replies)
Discussion started by: bodisha
4 Replies
SYSPROFILE(8)						      System Manager's Manual						     SYSPROFILE(8)

NAME
sysprofile - modular centralized shell configuration DESCRIPTION
sysprofile is a generic approach to configure shell settings in a modular and centralized way mostly aimed at avoiding work for lazy sysad- mins. It has only been tested to work with the bash shell. It basically consists of the small /etc/sysprofile shell script which invokes other small shell scripts having a .bash suffix which are contained in the /etc/sysprofile.d/ directory. The system administrator can drop in any script he wants without any naming convention other than that the scripts need to have a .bash suffix to enable automagic sourcing by /etc/sysprofile. This mechanism is set up by inserting a small shell routine into /etc/profile for login shells and optionally into /etc/bashrc and/or /etc/bash.bashrc for non-login shells from where the actual /etc/sysprofile script is invoked: if [ -f /etc/sysprofile ]; then . /etc/sysprofile fi For using "sysprofile" under X11, one can source it in a similar way from /etc/X11/Xsession or your X display manager's Xsession file to provide the same shell environment as under the console in X11. See the example files in /usr/share/doc/sysprofile/ for illustration. For usage of terminal emulators with a non-login bash shell under X11, take care to enable sysprofile via /etc/bash.bashrc. If not set this way, your terminal emulators won't come up with the environment defined by the scripts in /etc/sysprofile.d/. Users not wanting /etc/sysprofile to be sourced for their environment can easily disable it's automatic mechanism. It can be disabled by simply creating an empty file called $HOME/.nosysprofile in the user's home directory using e.g. the touch(1) command. Any single configuration file in /etc/sysprofile.d/ can be overridden by any user by creating a private $HOME/.sysprofile.d/ directory which may contain a user's own version of any configuration file to be sourced instead of the system default. It's names have just to match exactly the system's default /etc/sysprofile.d/ configuration files. Empty versions of these files contained in the $HOME/.syspro- file.d/ directory automatically disable sourcing of the system wide version. Naturally, users can add and include their own private script inventions to be automagically executed by /etc/sysprofile at login time. OPTIONS
There are no options other than those dictated by shell conventions. Anything is defined within the configuration scripts themselves. SEE ALSO
The README files and configuration examples contained in /etc/sysprofile.d/ and the manual pages bash(1), xdm(1x), xdm.options(5), and wdm(1x). Recommended further reading is everything related with shell programming. If you need a similar mechanism for executing code at logout time check out the related package syslogout(8) which is a very close compan- ion to sysprofile. BUGS
sysprofile in its current form is mainly restricted to bash(1) syntax. In fact it is actually a rather embarrassing quick and dirty hack than anything else - but it works. It serves the practical need to enable a centralized bash configuration until something better becomes available. Your constructive criticism in making this into something better" is very welcome. Before i forget to mention it: we take patches... ;-) AUTHOR
sysprofile was developed by Paul Seelig <pseelig@debian.org> specifically for the Debian GNU/Linux system. Feel free to port it to and use it anywhere else under the conditions of either the GNU public license or the BSD license or both. Better yet, please help to make it into something more worthwhile than it currently is. SYSPROFILE(8)
All times are GMT -4. The time now is 09:05 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy