Solved

Bash Script Help

Posted on 2013-12-16
5
334 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Learn by Doing. Anytime. Anywhere.

Do you like to learn by doing?
Our labs and exercises give you the chance to do just that: Learn by performing actions on real environments.

Hands-on, scenario-based labs give you experience on real environments provided by us so you don't have to worry about breaking anything.

Question has a verified solution.

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

If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
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…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

734 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