HELP!! A little help please..scripting.

HELP!! A little help please..scripting.

Post by TAP » Fri, 24 Sep 1999 04:00:00



        I have taken my first stab at scripting and found that it's alot harder
than it looks. Here's my script, can anyone help me fix it? It won't exit
if it doesn't find a,b, or c. I know there's a much better way.. Can anyone
help? It connects to the correct database, but if I put in something other
than a,b,or c, it tries to connect to who knows what!

Tom

Could someone show me an easier way to exit if the job doesn't find a,b, or
c? This way doesn't work.

#!/bin/ksh
echo "Please type instance name to connect to:
[A] DBAT
[B] ORD1
[C] DEMO

Quote:>>> "

read instance
if $instance -ne [[ a|A || b|B || c|C ]]
then
exit 1
else
case $instance in
a|A) DBASE=DOUG;;
b|B) DBASE=JEFF;;
c|C) DBASE=DEMO;;
esac
  export ORACLE_SID=$DBASE
fi
svrmgrl command="connect internal"
exit 0;
 
 
 

HELP!! A little help please..scripting.

Post by Jan Wuyt » Sat, 25 Sep 1999 04:00:00


How about...

#!/bin/ksh
echo "Please type instance name to connect to:
[A] DBAT
[B] ORD1
[C] DEMO

Quote:>>> "

read instance
case $instance in
a|A) DBASE=DOUG;;
b|B) DBASE=JEFF;;
c|C) DBASE=DEMO;;
*) exit 1;; ###### this is it
esac
  export ORACLE_SID=$DBASE
svrmgrl command="connect internal"
exit 0;

Cheers
--

      Jan Wuyts

 
 
 

HELP!! A little help please..scripting.

Post by Kenneth C Stah » Sat, 25 Sep 1999 04:00:00


Try this:

#!/bin/ksh
typeset -u Instance;
print "Please type instance name to connect to:
[A] DBAT
[B] ORD1
[C] DEMO

Quote:>>>\c"

read Instance;
if [[ ${Instance} = 'A' || ${Instance} = 'B' && ${Instance} = 'C' ]]
then
    case ${Instance} in
        A) DBASE='DOUG';;
        B) DBASE='JEFF';;
        C) DBASE='DEMO';;
    esac;
else
    print "Unknown selection: ${Instance}";
    exit 1;
fi
export ORACLE_SID=${DBASE};
svrmgrl command="connect internal"
exit 0;

or even simpler, try this:

#!/bin/ksh
typeset -u Instance='';
print -u1 "Please type instance name to connect to:
[A] DBAT
[B] ORD1
[C] DEMO

Quote:>>>\c"

read Instance;
case ${Instance} in
    A) DBASE='DOUG';;
    B) DBASE='JEFF';;
    C) DBASE='DEMO';;
    *) print "Unknown selection: ${Instance}";
       exit 1;
esac;
export ORACLE_SID=${DBASE};
svrmgrl command="connect internal"
exit 0;

>         I have taken my first stab at scripting and found that it's alot harder
> than it looks. Here's my script, can anyone help me fix it? It won't exit
> if it doesn't find a,b, or c. I know there's a much better way.. Can anyone
> help? It connects to the correct database, but if I put in something other
> than a,b,or c, it tries to connect to who knows what!

> Tom

> Could someone show me an easier way to exit if the job doesn't find a,b, or
> c? This way doesn't work.

> #!/bin/ksh
> echo "Please type instance name to connect to:
> [A] DBAT
> [B] ORD1
> [C] DEMO
> >>> "
> read instance
> if $instance -ne [[ a|A || b|B || c|C ]]
> then
> exit 1
> else
> case $instance in
> a|A) DBASE=DOUG;;
> b|B) DBASE=JEFF;;
> c|C) DBASE=DEMO;;
> esac
>   export ORACLE_SID=$DBASE
> fi
> svrmgrl command="connect internal"
> exit 0;

 
 
 

1. A little scripting help please

Hello Everyone!

I have not done any serious scripting for about 10 years...

I'm ashamed at how much I've forgotten...

If I wanted to take the output from a locate command and perform some
action on each file located...  How would I do that?
ie:
locate '.bak' | rm all these stupid .bak files

Oh, typically using the bash shell....

Thanks!

Matt Anderson

2. CSH: checking more than one string in a CASE statement

3. Bash Scripting: Little help with basic scripting

4. ppc server question

5. PLEASE PLEASE HELP Major problem with my SCSI & Redhat 5.0 PLEASE Help

6. Display problems

7. little script / command help

8. Several domains on same host

9. little help shell scripting

10. Newbie needs a little help on shell scripts (ksh)

11. A little help with a script?

12. Web page check script- need a little help

13. A little help needed with a script and crontab