The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
pass variable from awk to shell script user_prady Shell Programming and Scripting 3 04-17-2008 02:43 AM
help me in sending parameters from sqlplus script to unix shell script Hara Shell Programming and Scripting 2 01-29-2008 11:31 AM
Is it possible to pass variable from awk to shell script user_prady Shell Programming and Scripting 3 12-18-2007 06:06 AM
How to Pass variable to shell Script sam70 UNIX for Dummies Questions & Answers 5 08-23-2005 04:27 PM
How to pass Shell variables to sqlplus use them as parameters Jtrinh Shell Programming and Scripting 1 07-13-2005 01:15 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-12-2007
Registered User
 

Join Date: Jul 2007
Posts: 33
How to pass two or more parameters to the main in shell script

Hey Guys


from the below script what I understood is we are sending the the first parameter as input to the main (){} file
main > $LOGFILE 2>&1
but can we send two or three parameter as input to this main file as
main > $LOGFILE 2>&1 2>&2 like this

Can any one plz help I need to writ a script which takes three parameters

#!/usr/bin/ksh
DIRNAME=/web/local/orderlink/linkload/script
LOGDIR=/web/local/orderlink/linkload/logs
LOGFILE=$LOGDIR/process_stuck_csos.log
NUMARGS=$#
ARGI=$1

main()
{
DATESTAMP=`date +%Y%m%d%H%M%S`
SQL_TEMP_FILE=$DIRNAME/tmpcsosclean.sql
SQL_A="SET SERVEROUTPUT ON;\n
DECLARE\n
TYPE OrderList IS TABLE OF S_ORDR.ORDR_ID%TYPE INDEX BY BINARY_INTEGER;\n
listOrders OrderList;\n
\n
BEGIN\n
"

SQL_B="\nFORALL i IN listOrders.FIRST..listOrders.LAST\n
UPDATE s_ordr set ORDR_STAT_TXT = 'CSOS REJECTED'\n
where ordr_id = listOrders(i)\n
and ORDR_STAT_TXT = 'CSOS SIGNED/IN-PROG';\n
DBMS_OUTPUT.PUT_LINE(SQL%ROWCOUNT || ' row(s) actually updated.' );
COMMIT;
\n
END;
\n/
\nEXIT
"

. $DIRNAME/set_env.ksh

echo "----------------------------------------------------------------------"
echo $DIRNAME"/"$0
echo $DATESTAMP
echo "Using:"$ORACLE_SID

n=`grep -c '^[0-9]\{1,10\}$' $infile`
echo $n "order id(s) found to process in" $infile

if [ $n -lt 1 ]; then
echo "Nothing to do..."
exit 0;
fi

echo "Generating SQL";


echo $SQL_A > $SQL_TEMP_FILE
grep '^[0-9]\{1,10\}$' $infile | awk '{print "listOrders("NR") := "$1";"}' >> $SQL_TEMP_FILE
echo $SQL_B >> $SQL_TEMP_FILE

echo "Running SQL_PLUS"

sqlplus -s / @$SQL_TEMP_FILE

mv $SQL_TEMP_FILE $LOGDIR/proc_stuck_csos.sql.log
}

if [ $# != 1 ]; then
echo "Usage: $0 input-file"
exit 1
else
if [ ! -r $ARGI ]; then
echo "Error: File not found, or file unreadable!"
exit 1
else
infile=$ARGI
fi
fi

main > $LOGFILE 2>&1



Thanks in advance
I am desperate needed to code as quickly as possible
pinky
Reply With Quote
Google UNIX.COM
Forum Sponsor
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 03:14 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