INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

base script case statement error

base script case statement error

(OP)
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

RE: base script case statement error

Hi

Quote (rigstars2)

where is the error

in my case statment?
Nowhere. The error is somewhere else. The case you posted is syntactically valid.

Feherke.
http://feherke.github.com/

RE: base script case statement error

(OP)
thats what i thought but everytime i run it.. it keeps referencing
this area of my script.. thanks feherke

RE: base script case statement error

Hi

Quote (rigstars2)

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.
http://feherke.github.com/

RE: base script case statement error

(OP)
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

RE: base script case statement error

(OP)
btw, i added the missing parenthesis but still get the error message

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

RE: base script case statement error

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 cat <<EOF and EOF lines and the EOF line is not indented.

Quote (rigstars2)

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.
http://feherke.github.com/

RE: base script case statement error

(OP)
okay.. cool. Thanks Feherke!

RE: base script case statement error

(OP)
ok, i'll try dat. thanks

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close