Solved

Bash Script Help

Posted on 2013-12-16
5
325 Views
Last Modified: 2013-12-17
For some reason, the last line never executes.  I'm trying to get the script to write out the start time and finish time.
!/bin/bash
date >> /home/oracle/scripts/rebuild_index_start_time
ORACLE_HOME=/apps/app/oracle/product/11.2.0/db_1
export ORACLE_HOME
ORACLE_SID=BB60
export ORACLE_SID
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib
export LD_LIBRARY_PATH
PATH=$ORACLE_HOME/bin:$PATH
export PATH
/apps/app/oracle/product/11.2.0/db_1/bin/sqlplus sys/wiz as sysdba <<REBUILD_LIST_COMPLETE
set linesize 88
set termout off;
spool rebuild_index_list
select 'alter index '||owner||'.'||index_name ||' rebuild parallel 4 compute statistics;'
  from dba_indexes
    where (dba_indexes.owner = 'BB_BB60'
    and dba_indexes.num_rows >= 3000000 )
UNION
select 'alter index '||owner||'.'||index_name ||' rebuild parallel 4 compute statistics;'
  from dba_indexes
    where (dba_indexes.owner like '%CMS%'
    and dba_indexes.num_rows >= 3000000 )  ;
quit;
spool off;
REBUILD_LIST_COMPLETE
grep alter rebuild_index_list.lst > rebuild_index_list.sql
sed -i '/select/d' ./rebuild_index_list.sql
sed -i '/where/d' ./rebuild_index_list.sql
/apps/app/oracle/product/11.2.0/db_1/bin/sqlplus sys/wiz as sysdba  <<REBUILD_COMPLETE
@rebuild_index_list.sql;
quit
REBUILD_COMPLETE
date >> /home/oracle/scripts/rebuild_index_finish_time
0
Comment
Question by:xoxomos
5 Comments
 
LVL 10

Expert Comment

by:abbright
ID: 39722535
Try putting a newline at the end of the file.
0
 
LVL 68

Assisted Solution

by:woolmilkporc
woolmilkporc earned 250 total points
ID: 39722630
Check if you have some nonprintable characters in the file, particularly at the line ends:

cat -v scriptname

Something strange?

If in doubt, please remove the lines containing

REBUILD_COMPLETE

REBUILD_LIST_COMPLETE

and write them new by hand (no copy and paste!)
0
 
LVL 48

Accepted Solution

by:
Tintin earned 250 total points
ID: 39723393
Make sure there is no whitespace after either REBUILD_COMPLETE
0
 

Author Comment

by:xoxomos
ID: 39724985
Tintin!!!!   Long time :-)
Looks like it's working now.  Thanks all.
0
 

Author Closing Comment

by:xoxomos
ID: 39724994
Mil gracias
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now