Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Bash Script Help

Posted on 2013-12-16
5
Medium Priority
?
336 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 1000 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 1000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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ā€¦
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
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.:
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses

730 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