Sponsored Content
Full Discussion: Issue with the shell script
Top Forums Shell Programming and Scripting Issue with the shell script Post 302168370 by viv1 on Monday 18th of February 2008 06:28:39 AM
Old 02-18-2008
Issue with the shell script

hi , this script was devloped by somebody whome I dont know way back
# cat run_ucid.sh
#!/bin/csh
# run_ucid.sh
#
# This is a simple shell script that will start an application in
# the background and restart the application if it stops. Upon
# termination an email message is sent and the app is restarted by
# default. To disable automatic restart, the script may be started
# with the '-x' command line argument. (Actually, any command line
# argument should have that effect.) Start the app with the nohup
# command allow it to run after logging out.
#
# Instructions:
# 1. Set the variables in the next section for your environment.
# 2. Ensure that the script is executable by all (chmod 755 scriptname).
# 3. Ensure that the script is installed on a host with a mail server.
# 4. Syntax: nohup run_ucid.sh -x & (The -x is optional)
#
# Copyright (c) 2007, Genesys Professional Services. All rights reserved.
#
# Thank you for choosing Genesys Professional Services.

# ---------------------------------------------------------------------------
# SET THESE VARIABLES
# ---------------------------------------------------------------------------
# Do not modify anything on the left of the equal sign.

# Set the email subject
set SUBJECT = "ALERT FROM MMAS27"

# Set a brief email message
set MESSAGE = "UCID terminated."

# Set the email recipient; separate multiple addresses with commas
set RECIPIENT = "rgundermann@reliant.com"

# Set the absolute path to the application
set APPLICATION = "/gcti/UCIDPrimary/UCID-1.6.0/bin/UCID start"

# Set the application name (used by ps command)
set APPNAME = "UCID"

# ---------------------------------------------------------------------------
# DO NOT MODIFY THE SCRIPT BELOW THIS LINE
# ---------------------------------------------------------------------------

start:
$APPLICATION &
set STATE=0
While ($STATE=1)
sleep 5
set COUNT = `ps -ef | grep -c $APPNAME`
if ($COUNT > 1) then
set STATE=1
else
echo $MESSAGE | mailx -s "$SUBJECT" $RECIPIENT
if ($#argv == 0) then
sleep 1
goto start
endif
endif
end
echo Terminating script ...

#


on doing a test run this is the error it gives
# sh -x run_ucid.sh -x &
[1] 4354244
# + set SUBJECT = ALERT FROM MMAS27
+ set MESSAGE = UCID terminated.
+ set RECIPIENT = rgundermann@reliant.com
+ set APPLICATION = /gcti/UCIDPrimary/UCID-1.6.0/bin/UCID start
+ set APPNAME = UCID
+ start:
run_ucid.sh[46]: start:: not found.
+ set STATE=0
run_ucid.sh[49]: 0403-057 Syntax error at line 49 : `(' is not expected.

line 49 is the while loop line , please let me know why is this error coming
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Issue with a shell script

Hi All, I have an issue in writing the shell script to install a webserver on UNIX system. My shell script look something like this. ------------------------------------------------------------ echo "start of the script" #! /bin/sh cd /home/path echo | setup.hp -is:javaconsole -console... (4 Replies)
Discussion started by: vishalm
4 Replies

2. UNIX for Dummies Questions & Answers

Issue with shell Script file

Hi, I created the following shell script file : bash-3.00$ more Unlock_Statistics1.sh #!/usr/bin/ksh ORACLE_SID=prsal02; export ORACLE_SID NLS_LANG=AMERICAN_AMERICA.AL32UTF8; export NLS_LANG sqlplus -s /nolog << EOF connect / as sysdba ; set serveroutput on size 1000000; execute... (1 Reply)
Discussion started by: jalpan.pota
1 Replies

3. Shell Programming and Scripting

Help me with following issue using shell script

Hi Folks, I am looking for a script where that should show the progress bar while running a process Ex: while copying a file of size say 2 GB it should start the process as (0 %) and at the end it should show (100%) Thanks in Advance Phani. (4 Replies)
Discussion started by: phanivarma
4 Replies

4. UNIX for Dummies Questions & Answers

Shell script emailing issue

Hi, Im writing a shell script: #!/bin/bash #Send process which has exceeded 25% # echo 'pri pid user nice pcpu command' > /export/home/tjmoore/file2 # if ps -eo pri,pid,user,nice,pcpu,comm | awk '{if($5 >= 25)print $0}' >> /export/home/tjmoore/file2 2>/dev/null # # # then... (1 Reply)
Discussion started by: jay02
1 Replies

5. Shell Programming and Scripting

Issue in TC Shell Script

I have a script in TC shell, for some reason its not working. I'm trying to kick off a script if there are any files in a particular directory "/sample/test3" Can anyone point out the issue in the same #!/usr/bin/tcsh while true do if ls /sample/test3 >& /dev/null ; then... (2 Replies)
Discussion started by: gaugeta
2 Replies

6. Shell Programming and Scripting

Issue with shell script

I found a post from a user requesting help rounding numbers. The script provided by Scrutinizer works fine most of the time but it errors out when trying to round these numbers: 30224939 50872456 20753012 They have in common, a zero in the second digit from left to right. Can someone help... (1 Reply)
Discussion started by: Dennis_Ayala
1 Replies

7. Shell Programming and Scripting

Issue in shell script variables

Hi, I have a file at $HOME/t.txt, below is file content cat $HOME/t.txt CUSTOMER_${REGION}.out Am using this file content in one script $HOME/samp.sh, below is the script #!/bin/bash REGION=USA x=`cat ${HOME}/t.txt` echo $x Am getting following output.. CUSTOMER_${REGION}.out ... (3 Replies)
Discussion started by: shieksir
3 Replies

8. Shell Programming and Scripting

Issue in shell script

item,quantity,unit price,total tea,1,1,1 coffee,3,4,12 sugar,5,2.5,12.5 tea,2,1,3 coffee,2,4,8 i have got the above file with following questions: need to get the total value: which i got using : a=0 for b in `cut -f4 -d ',' log` do c=`echo $a + $b | bc` a=$c done echo "$a and $c" ... (9 Replies)
Discussion started by: bhupeshchavan
9 Replies

9. Shell Programming and Scripting

Shell script issue

Below is my script. However when i run it, i get the below error ./dummy.sh: line 27: syntax error: unexpected end of file #!/bin/bash while : do read -r INPUT_STRING case $INPUT_STRING in test) echo "Please enter id no : " read... (4 Replies)
Discussion started by: chandraprakash
4 Replies

10. Shell Programming and Scripting

Performance Issue - Shell Script

Hi, I am beginner in shell scripting. I have written a script to parse file(s) having large number of lines each having multiple comma separated strings. But it seems like script is very slow. It took more than 30mins to parse a file with size 120MB (523564 lines), below is the script code ... (4 Replies)
Discussion started by: imrandec85
4 Replies
exit(1)                                                            User Commands                                                           exit(1)

NAME
exit, return, goto - shell built-in functions to enable the execution of the shell to advance beyond its sequence of steps SYNOPSIS
sh exit [n] return [n] csh exit [ ( expr )] goto label ksh *exit [n] *return [n] DESCRIPTION
sh exit will cause the calling shell or shell script to exit with the exit status specified by n. If n is omitted the exit status is that of the last command executed (an EOF will also cause the shell to exit.) return causes a function to exit with the return value specified by n. If n is omitted, the return status is that of the last command exe- cuted. csh exit will cause the calling shell or shell script to exit, either with the value of the status variable or with the value specified by the expression expr. The goto built-in uses a specified label as a search string amongst commands. The shell rewinds its input as much as possible and searches for a line of the form label: possibly preceded by space or tab characters. Execution continues after the indicated line. It is an error to jump to a label that occurs between a while or for built-in command and its corresponding end. ksh exit will cause the calling shell or shell script to exit with the exit status specified by n. The value will be the least significant 8 bits of the specified status. If n is omitted then the exit status is that of the last command executed. When exit occurs when executing a trap, the last command refers to the command that executed before the trap was invoked. An end-of-file will also cause the shell to exit except for a shell which has the ignoreeof option (See set below) turned on. return causes a shell function or '.' script to return to the invoking script with the return status specified by n. The value will be the least significant 8 bits of the specified status. If n is omitted then the return status is that of the last command executed. If return is invoked while not in a function or a '.' script, then it is the same as an exit. On this man page, ksh(1) commands that are preceded by one or two * (asterisks) are treated specially in the following ways: 1. Variable assignment lists preceding the command remain in effect when the command completes. 2. I/O redirections are processed after variable assignments. 3. Errors cause a script that contains them to abort. 4. Words, following a command preceded by ** that are in the format of a variable assignment, are expanded with the same rules as a vari- able assignment. This means that tilde substitution is performed after the = sign and word splitting and file name generation are not performed. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
break(1), csh(1), ksh(1), sh(1), attributes(5) SunOS 5.10 15 Apr 1994 exit(1)
All times are GMT -4. The time now is 04:52 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy