The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Input parameters mpang_ Shell Programming and Scripting 3 01-07-2007 05:33 PM
DB2 stored procedure (with input parameters) from script mpang_ Shell Programming and Scripting 1 12-13-2006 04:12 AM
Max NO of parameters Shivdatta Shell Programming and Scripting 1 07-24-2006 05:11 AM
How to prompt for input & accept input in ONE line newbie168 Shell Programming and Scripting 2 09-27-2005 02:02 AM
Accept input parameters lloydnwo Shell Programming and Scripting 2 09-14-2004 04:47 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-19-2007
Registered User
 

Join Date: Feb 2007
Posts: 2
Stumble this Post!
input parameters pls help!

Hi i am a newbie who is trying to input parameters into this script, but not sure where to start.

The parameters that need to be input are the baseline label "abc.0111.BL " mantioned bellow, and database string "abc/abcp@db2 @counter.sql "
Environment: Windows XP
Running script: Cygwin 3.2

If anyone can help me, or try to direct me where to go from there i'll really appreciate.
Thanks.

Code:
#!/bin/bash

SCRIPT_DIR=$(dirname $0)
SCRIPT_DIR=$(cd $SCRIPT_DIR && pwd)
DATA_DIR=${SCRIPT_DIR}/../../installer/data/
SOURCE_DIR_MAINT=/cygdrive/c/maint_view/RBS

echo "######################UPDATING MAINTANANCE VIEW##########################  "
#update view 
(cd $SOURCE_DIR_MAINT; cleartool update) >log.lst

cd $DATA_DIR
cleartool find . -name '*.sql' -cview -version '{!lbtype(abc.0111.BL)}' -nxname -print | sed -e 's/[.]\\//g' -e 's/_data[.]sql//g' | sort >file.lst
echo ===============================================================================================
for f in `cat file.lst`; do count=$(grep "insert into" ${f}_data.sql|wc -l); echo "$f,$count"; done
echo ===============================================================================================
echo "set heading off;" >counter.sql
for f in `cat file.lst`; do echo "select '$f,'||count(*) from $f;" ; done >>counter.sql
echo "quit" >> counter.sql
cat counter.sql
for f in `cat file.lst`; do count=$(grep "insert into" ${f}_data.sql|wc -l); echo "$f,$count"; done >version_controlcount.txt
sqlplus -S abc/abcp@db2 @counter.sql | sed -e '/^$/d' >db_count.txt
cat db_count.txt
diff version_control_count.txt db_count.txt
exit 0
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 02-19-2007
aigles's Avatar
Registered User
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,211
Stumble this Post!
You can do something like that :
Code:
##!/bin/bash

SCRIPT_DIR=$(dirname $0)
SCRIPT_DIR=$(cd $SCRIPT_DIR && pwd)
DATA_DIR=${SCRIPT_DIR}/../../installer/data/
SOURCE_DIR_MAINT=/cygdrive/c/maint_view/RBS

# Get parameters

if [ $# -lt 2 ]
then
   echo "Usage: $0 label database_string" 1>&2
   exit 1
fi
Label=$1 ; shift
Database_string="$*"          


echo "######################UPDATING MAINTANANCE VIEW##########################  "
#update view
(cd $SOURCE_DIR_MAINT; cleartool update) >log.lst

cd $DATA_DIR
cleartool find . -name '*.sql' -cview -version "{!lbtype(${Label})}' -nxname -print | \
sed -e 's/[.]\\//g' -e 's/_data[.]sql//g'                                           | \
sort >file.lst

echo ===============================================================================================
for f in `cat file.lst`; do count=$(grep "insert into" ${f}_data.sql|wc -l); echo "$f,$count"; done
echo ===============================================================================================

echo "set heading off;" >counter.sql
for f in `cat file.lst`; do echo "select '$f,'||count(*) from $f;" ; done >>counter.sql
echo "quit" >> counter.sql
cat counter.sql
for f in `cat file.lst`; do count=$(grep "insert into" ${f}_data.sql|wc -l); echo "$f,$count"; done >version_controlcount.txt
sqlplus -S ${Database_string} | sed -e '/^$/d' >db_count.txt
cat db_count.txt
diff version_control_count.txt db_count.txt
exit 0
Jean-Pierre.
Reply With Quote
  #3 (permalink)  
Old 02-20-2007
Registered User
 

Join Date: Feb 2007
Posts: 2
Stumble this Post!
Thank you so much, i'll test it from work.

Quote:
Originally Posted by aigles
You can do something like that :
Code:
##!/bin/bash

SCRIPT_DIR=$(dirname $0)
SCRIPT_DIR=$(cd $SCRIPT_DIR && pwd)
DATA_DIR=${SCRIPT_DIR}/../../installer/data/
SOURCE_DIR_MAINT=/cygdrive/c/maint_view/RBS

# Get parameters

if [ $# -lt 2 ]
then
   echo "Usage: $0 label database_string" 1>&2
   exit 1
fi
Label=$1 ; shift
Database_string="$*"          


echo "######################UPDATING MAINTANANCE VIEW##########################  "
#update view
(cd $SOURCE_DIR_MAINT; cleartool update) >log.lst

cd $DATA_DIR
cleartool find . -name '*.sql' -cview -version "{!lbtype(${Label})}' -nxname -print | \
sed -e 's/[.]\\//g' -e 's/_data[.]sql//g'                                           | \
sort >file.lst

echo ===============================================================================================
for f in `cat file.lst`; do count=$(grep "insert into" ${f}_data.sql|wc -l); echo "$f,$count"; done
echo ===============================================================================================

echo "set heading off;" >counter.sql
for f in `cat file.lst`; do echo "select '$f,'||count(*) from $f;" ; done >>counter.sql
echo "quit" >> counter.sql
cat counter.sql
for f in `cat file.lst`; do count=$(grep "insert into" ${f}_data.sql|wc -l); echo "$f,$count"; done >version_controlcount.txt
sqlplus -S ${Database_string} | sed -e '/^$/d' >db_count.txt
cat db_count.txt
diff version_control_count.txt db_count.txt
exit 0
Jean-Pierre.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 11:36 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0