Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

base script case statement error 2

Status
Not open for further replies.

rigstars2

Instructor
Dec 18, 2011
64
US
i get a syntax error..end of file error.. where is the error
in my case statment? thanks

case "$CON" in
[Ee][1])
funct1 $CON
;;
[Dd][1])
funct2 $CON
;;
*)
echo " Error: Invalid argument..."
usage
;;
esac
 
thats what i thought but everytime i run it.. it keeps referencing
this area of my script.. thanks feherke
 
Hi

rigstars2 said:
everytime i run it.. it keeps referencing

this area of my script..
When there is a mismatch in opening/closing nested block delimiters of any kind, many compilers and interpreters will indicate the place they observed the problem. That is usually where it becomes obvious a delimiter which had to occur before that point was not found. So look from the indicated point backward. Or post ( or upload to a file sharing service ) the entire script, so we can help with it.

Feherke.
[link feherke.github.com/][/url]
 
I've looked it over and over.. I'm definitely stumped..here's
the entire script.. thanks feherke!


#!/bin/bash

PROGNAME=`basename $0`
usage() {
cat <<EOF
Usage: $PROGNAME {edb1|nsa1|esd1|odb1}

Example: restart odb1
Example: sudo su - pwxagent restart nsa1
EOF
exit
}

restart_con() {
cd /nfs/informatica_pwx/logs/$CON/condenser/
sleep 1
rm -rf nohup.out 1>&2
sleep 1
nohup pwxccl cs=pwxccl_$CON.cfg config=/nfs/informatica_pwx/logs/$CON/listener/$CON_dbmover.cfg &
sleep 1
echo "$CON condenser restarted successfully..."
exit
}

chk_con() {
shopt -s nocasematch
DB=`ps -ef | grep pwxccl | grep $CON | cut -d\/ -f5`
if [[ $DB == $CON ]]; then
echo "$CON condenser already running..."
shopt -u nocasematch
else
restart_con $CON
fi
}

if [[ ! "`whoami`" == "pwxagent" ]]; then
echo
echo " Error: Must be run as pwxagent | sudo su - pwxagent"
usage
echo
fi

if [[ $# -lt 1 ]]; then
echo
echo " Error: Must have at least 1 argument..."
usage
echo
fi

if [[ $# -gt 1 ]]; then
echo
echo " Error: Must have no more than 1 argument..."
usage
echo
fi

CON=$1
case "$CON" in
[Ee][Ss][Dd][1])
chk_con $CON
;;
[Nn][Ss][Aa][1])
chk_con $CON
;;
[Oo][Dd][Bb][1])
chk_con $CON
;;
[Ee][Dd][Bb])[1]
chk_con $CON
;;
*)
echo " Error: Invalid condenser argument..."
usage
;;
esac
 
btw, i added the missing parenthesis but still get the error message

[Ee][Dd][Bb])[1]) <--
chk_con $CON
 
Hi

No error neither there. At least not with Bash and MKsh.

One possible problem ( which may be vanished on its way to me due to the two copy & paste operations ) : there are trailing spaces after the here-document delimiters. So make sure there are no spaces ( or other whitespace characters ) at the end of the [tt]cat <<EOF[/tt] and [tt]EOF[/tt] lines and the [tt]EOF[/tt] line is not indented.

rigstars2 said:
btw, i added the missing parenthesis but still get the error message



[Ee][Dd][Bb])[1]) <--

chk_con $CON
As far as I understand the task, there is no need for that.

Feherke.
[link feherke.github.com/][/url]
 
I'd replace this this:
[Ee][Dd][Bb])[1])
with this:
[Ee][Dd][Bb]1)

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top