Solved

Bash Script Help

Posted on 2013-12-16
5
329 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Fine Tune your automatic Updates for Ubuntu / Debian
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will giveā€¦
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

770 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