Wednesday, 15 September 2010

unix - passing a string variables into a function ksh -



unix - passing a string variables into a function ksh -

i'm trying pass string variables within function (the bteq work) can't seem work. seek this:

td_instance="one" user="usr1" pass="pass1" schemaname="schemaa" tblname="tablea" query="sel '>'||count(*) $schemaname.$tblname" query_td() { bteq .logon $td_instance/$user,$pass database $schemaname; .set width 1000; .set titledashes off; $1; .logoff; .quit; .exit } echo $(query_td << eof |grep '^>' |sed -e "s/^>//" eof "$query")

and maintain getting error:

-ksh: .: syntax error: `)' unexpected

i've moved bunch of compenents around still can't seem work..i maintain getting same error when move things around not sure wrong here know is....

---------update------------

so based on comments below...i've tried simplify create easier debug...i've got function now...

query_td() { bteq "$(cat $home/.tdlogon) database $schemaname; .set width 1000; .set titledashes off; $1 .exit" } query_td $query

but seems run

bteq "$(cat $home/.tdlogon)

but reason doesn't run past portion of function. starts bteq programme , logs in, sits in bteq waiting commands...

here how able work...moved eof within statement...i think guys refering too, right?

td_query () { bteq << eof |grep '^>' |sed -e "s/^>//" $(cat $home/.tdlogon) database $schemaname; .set width 1000; .set titledashes off; $1 .logoff; .quit; .exit eof } echo "the date is: " $(td_query "sel '>'||current_date;")

unix ksh

No comments:

Post a Comment