The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 05:43 AM
help me in sending parameters from sqlplus script to unix shell script Hara Shell Programming and Scripting 2 01-29-2008 03:31 PM
Is it possible to pass variable from awk to shell script user_prady Shell Programming and Scripting 3 12-18-2007 10:06 AM
How to Pass variable to shell Script sam70 UNIX for Dummies Questions & Answers 5 08-23-2005 07:27 PM
How to pass Shell variables to sqlplus use them as parameters Jtrinh Shell Programming and Scripting 1 07-13-2005 04:15 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-12-2007
pinky pinky is offline
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
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:47 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0