Solved

Bash Script Help

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Suggested Solutions

rdate is a Linux command and the network time protocol for immediate date and time setup from another machine. The clocks are synchronized by entering rdate with the -s switch (command without switch just checks the time but does not set anything). …
Fine Tune your automatic Updates for Ubuntu / Debian
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

911 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

15 Experts available now in Live!

Get 1:1 Help Now