The original AWK had bugs.  So New AWK was written to fix those; and I
suppose some additional functionality was added while they were at it.  I
haven't verified it for the case of awk/nawk, but often these kinds of
programs end up being a single program that examines its command line to see
how it was called; then it behaves accordingly.

It is indeed a mystery as to why the Linux cognoscenti left awk in the
distribution, but tossed nawk when -- as they look down their collective
nose and wave their collective finger at you -- you should be using gawk.

Now there's always the duct tape and bailing wire rig of soft links ....


> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: Monday, August 04, 2003 1:59 PM
> To: Multiple recipients of list ORACLE-L
> Subject: RE: One for bash experts....
> 
> 
> Yes, there are differences between nawk and awk.
> 
> Scripts written for nawk may not work on awk.
> 
> Don't ask me why, check the man pages. :)
> 
> Jared
> 
> 
> 
> 
> 
> "Matthew Zito" <[EMAIL PROTECTED]>
> Sent by: [EMAIL PROTECTED]
>  08/04/2003 11:19 AM
>  Please respond to ORACLE-L
> 
>  
>         To:     Multiple recipients of list ORACLE-L 
> <[EMAIL PROTECTED]>
>         cc: 
>         Subject:        RE: One for bash experts....
> 
> 
> It's looking for the command "nawk" - either find a source 
> package and 
> install it, or change your script to call awk instead.  I'm 
> not sure of 
> any differences between awk and nawk, but you could give it a shot.
>  
> Thanks,
> Matt
> --
> Matthew Zito
> GridApp Systems
> Email: [EMAIL PROTECTED]
> Cell: 646-220-3551
> Phone: 212-358-8211 x 359
> http://www.gridapp.com 
> -----Original Message-----
> Sent: Monday, August 04, 2003 10:40 AM
> To: Multiple recipients of list ORACLE-L
> 
> I've got the following script that works fine on most 
> flavours of unix 
> apart from Linux...I think I must be going mad as I can't see 
> where the 
> problem is
>  
> I get the following error when i invoke it.....
>  
> oracle ukwsv71 > usedb uktst233
> bash: nawk: command not found
> bash: nawk: command not found
> bash: nawk: command not found
> bash: nawk: command not found
> bash: nawk: command not found
> bash: nawk: command not found
> bash: nawk: command not found
> ORACLE_HOME = [/oracle/app/oracle] ? 
>  
> TIA
>  
> #-------------------------------------------------------------
> -----------------
> #       File:           usedb
> #       System:         Information System
> #       Description:    This validates and sets up the oracle 
> environment
> #                       based on the database name.
> #       Parameters:     database name upper or lower case
> # 
> #       Notes:          "This should be bomb proof but so were many 
> #embasies!"
> #                       It runs in the current shell . 
> #
> #       Korn/Bash command line usage 
> #       ----------------------------
> #       . /proj/oracle/scripts/usedb ukprd33
> #
> #       Bourne command line usage 
> #       ----------------------------
> #       usedb=ukprd33 . /proj/oracle/scripts/usedb
> # 
> #       Interactive use Korn/Bourne or Bash
> #       -----------------------------------
> #       . /proj/oracle/scripts/usedb
> #
> oracle ukwsv71  > cat usedb
> #-------------------------------------------------------------
> -----------------
> #       File:           usedb
> #       System:         Information System
> #       Description:    This validates and sets up the oracle 
> environment
> #                       based on the database name.
> #       Parameters:     database name upper or lower case
> # 
> #       Notes:          "This should be bomb proof but s! o were many 
> embasies!"
> #                       It runs in the current shell . 
> #
> #       Korn/Bash command line usage 
> #       ----------------------------
> #       . /proj/oracle/scripts/usedb ukprd33
> #
> #       Bourne command line usage 
> #       ----------------------------
> #       usedb=ukprd33 . /proj/oracle/scripts/usedb
> # 
> #       Interactive use Korn/Bourne or Bash
> #       -----------------------------------
> #       . /proj/oracle/scripts/usedb
> #
> #       Using an alias Korn or Bash
> #       ---------------------------
> #       alias usedb='. /proj/oracle/scripts/usedb'
> #       usedb uktst33
> #         or
> #       usedb
> #
> # Date          Who     Comments
> # ========      ===     ========
> # 20-08-98      MJE     (Kentlong Ltd.) Glaxowellcome
> # 28-04-98      MJE     Updated for HPUX
> # 10-06-99      MJE     Hunt for oratab back in looking at 
> listener is 
> #                       unreliable. Looks for the tnsnames file in 
> standard
> #                       place. Removes all environment 
> setings and oracle 
> #                       path seting at the start.
> # 08-07-99      MJE     Changed to work in bourne shell from 
> the command 
> line.
> # 30-11-99      IAF     Test for Oracle 8.1.5 so as to set up 
> LD_LIBRARY_PATH
> #                       to point to additional directory  
> /usr/ucblink.
> # 06-03-00      MJE     Changed code to ignore links when looking for 
> oratab
> # 07 Aug 2001 M Sabet   Fixed the problem with ! the new 
> format of the 
> combined 
> #       merged fSB and fGW tnsnames file. This script 
> basically stopped 
> working.
> #       But now it should cope with both the old and new 
> combined formats. 
> It is
> #       always best to stick to just one format and 
> indentation for the 
> tnsnames
> #       entries if possible. It makes it easier to work with.
> #
> #-------------------------------------------------------------
> -----------------
> # Set up names for Information and error processing
> NODENAME=`uname -n`
> SCRIPT=$0
> INFO=$NODENAME"::usedb: "
> ERROR=$NODENAME"::usedb: Error "
> # If the operating system is HP-UX then the $NAWK command = 
> awk else use 
> $NAWK.
> # Under HP-UX $NAWK does not exist but the $NAWK functions 
> are included 
> with awk
> if [ `uname -s|awk '{print substr($0,1,3)}'` = "HP-" ] ; then
>   NAWK=awk
> else
>   NAWK=nawk
> fi
> if [ -z "$usedb" ] ; then
>   usedb=$1
> fi
> unset OTAB OTABFILE TNSNAMES VNAM LOCATION TWO_TASK 
> ORACLE_SID ORACLE_HOME
> # If the database name has not been passed in on the command line
> while [ -z "$usedb" ] ; do
>   echo "Please enter database name  e.g. UKTST01 >"
>   read usedb
>   echo
> done
> 
> # Fiddle abort loop
> while true ; do
> # Find the ORATAB file
> OTAB=`find /etc /var/opt -type f -name oratab -print 2>/dev/null`
> if [ -z "$OTAB" ] ; then
>   error "The ORATAB file was not found."
>   unset OTAB OTABFILE TNSNAMES VNAM LOCATION usedb
>   break
> fi
> # Strip multiple /usr/local/bin (s) from the path and make sure 
> /usr/local/bin
> # is first
> PATH="/usr/local/bin:"`echo $PATH|sed 's?/usr/local/bin??g'`
> # Strip all $ORACLE_HOME/bin (s) in oratab from the path
> ORACLE_HOMES=`awk -F: '/\*/ {next} /#/ {next} /^$/ {next} {print $2}' 
> $OTAB` 
> for ORACLE_HOME in $ORACLE_HOMES
> do
>   PATH=`echo $PATH|sed 's?\:'$ORACLE_HOME'\/bin??g'`
> done
> # Replace the two sets of Colons :: with : due to removal of 
> other bits
> PATH=`echo $PATH|sed 's?\:\:?:?g'`
> # Remove last char if the last char is a colon
> PATH=`echo $PATH|awk '{ if (substr($0,length(),1) == ":") print 
> substr($0,1,len`
> export PATH
> # Set the ORACLE_HOME to the first entry in the oratab
> ORACLE_HOME=`awk -F: '/#/ {next} /^$/ {next} {print $2}' 
> $OTAB|head -1`
> # Locate the tnsnames file
> if [ -z "$TNS_ADMIN" ] ; then
> # Look in standard place
>   TNSNAMES=$ORACLE_HOME/network/admin/tnsnames.ora
> else
> # TNS_ADMIN overrides the standard position of tnsnames
>   TNSNAMES=$TNS_ADMIN/tnsnames.ora 
> fi
> unset ORACLE_HOME
> if [ ! -f "$TNSNAMES" ] ; then
>   echo $ERROR "$TNSNAMES not found, exiting ..."
>   unset OTAB OTABFILE TNSNAMES VNAM LOCATION usedb
>   break
> fi
> # Force database name to uppercase
> usedb=`echo $usedb|$NAWK '{print toupper($1)}'`
> # Validate database name in tnsnames
> #   Convert tnsnames to uppercase and remove all spaces (NAWK) 
> #   grep out usedb= (GREP)
> #   Strip off the = character (SED)
> #VNAM=`$NAWK '{gsub(/ /,""); print toupper($0)}' $TNSNAMES|grep 
> "$usedb="|sed ' 
> VNAM=`$NAWK '{gsub(/ /,""); gsub(/      /,""); print toupper($0)}' 
> $TNSNAMES|gr`
> 
> # Compare the result of search with original to ensure not 
> partial string
> if [ "$usedb" != "$VNAM" ] ; then
> # Unset all the oracle logicals due to error in name
>   echo $ERROR
>   echo "Environment not set up for database $usedb name not found in" 
>   echo "$TNSNAMES"
>   unset OTAB OTABFILE TNSNAMES VNAM LOCATION usedb
>   break
> else
> # Get the oracle sid from the tnsnames file for the database
> #   Convert tnsnames to uppercase and remove all spaces (NAWK1)
> #   Get all lines from $usedb= to SID= substituting SID= with 
> ? (NAWK2)
> #   Get the last line which now = '?SID' (TAIL) 
> #   Use ? as the field delimiter and print the second field SID  (AWK)
>   ORACLE_SID=`$NAWK '{gsub(/ /,"");print toupper($0)}' 
> $TNSNAMES|$NAWK 
> '/'$used`
>   export ORACLE_SID
> fi
> # If SID not in oratab then this is a remote database
> #   Change to upper case and remove comment lines from oratab (NAWK)
> #   Match $ORACLE_SID with line in oratab and print field 1=SID (AWK) 
> #   Compare with original SID to check that the sid is not a partial 
> string
> if [ "`$NAWK '/#/ {next} {print toupper($0)}' $OTAB|awk -F: 
> '/'$ORACLE_SID'/{ p]
> then
>  
> # Remote database
> # Set the ORACLE_SID as the first entry in the oratab file
> #   Remove comment lines from oratab (GREP)
> #   Remove blank lines (SED)
> #   Print the first field. (AWK)
> #   Print the first line, first sid (HEAD)
>   ORACLE_SID=`grep -v "#" $OTAB|sed '/^$/d'|awk -F: '{print 
> $1}'|head -1`
>   export ORACLE_SID
> # Set up the two task environment variable 
>   TWO_TASK=$usedb;export TWO_TASK
>   LOCATION="remote"
> else
> #  We have now found the SID in the oratab sug! esting that 
> it is local
> #  , we need to know if the sid is upper or lower case as the 
> user may 
> #  have typed in the wrong case.
>   if [ "`$NAWK -F: '/#/ {next} /'$ORACLE_SID'/ {print $1}' $OTAB`" != 
> "$ORACLE_]
>   then
> #   lowercase the sid
>     ORACLE_SID=`echo $ORACLE_SID|$NAWK '{print tolower($1)}'` 
>     export ORACLE_SID 
>   fi
>   LOCATION="local"
> fi
> # Run oraenv in the normal way
> ORAENV_ASK=NO;export ORAENV_ASK
> if [ ! -f /usr/local/bin/oraenv ] ;then
>   "/usr/local/bin/oraenv not found or oracle not on machine."
>   unset OTAB OTABFILE TNSNAMES VNAM LOCATION usedb
>   break
> fi
> . /usr/local/bin/oraenv 
> ORAENV_ASK=YES;export ORAENV_ASK
> if [ "$LOCATION" = "remote" ] ; then 
>   unset ORACLE_SID
> fi
> # If operating system SunOS then dynamic library path must be set
> if [ `uname -s` = "SunOS" ]; then
> # 30 Nov 99
> # Following added if using Oracle 8.1.5. The "proc" utiltiy (pro*c 
> compiler)
> # locations /usr/ucblib for library files must be added. 
> # We test for specifically Oracle 8.1.5. ( 8.1.6 may be different).
> ora_8=`echo $ORACLE_HOME |  grep -c  '8.1.5'` 
>   if [  $ora_8 -eq 0  ]
>     then
>       LD_LIBRARY_PATH=${ORACLE_HOME}/lib:/usr/openwin/lib:/usr/dt/lib 
>       export LD_LIBRARY_PATH 
>   else
>       LD_LIBRARY_PATH=${ORACLE_HOME}/lib:/usr/ucblib 
>       export LD_LIBRARY_PATH 
>   fi
> fi
> echo $INFO
> echo "Oracle "`basename $ORACLE_HOME`" Set up for $LOCATION database 
> $usedb"
> unset OTAB OTABFILE TNSNAMES VNAM LOCATION usedb
> # end of abort loop
> break
> done
>  
>  
> 
> Yahoo! Plus - For a better Internet experience
> 
> 
> -- 
> Please see the official ORACLE-L FAQ: http://www.orafaq.net
> -- 
> Author: 
>   INET: [EMAIL PROTECTED]
> 
> Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
> San Diego, California        -- Mailing list and web hosting services
> ---------------------------------------------------------------------
> To REMOVE yourself from this mailing list, send an E-Mail message
> to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
> the message BODY, include a line containing: UNSUB ORACLE-L
> (or the name of mailing list you want to be removed from).  You may
> also send the HELP command for other information (like subscribing).
> 
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.net
-- 
Author: Stephen Lee
  INET: [EMAIL PROTECTED]

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).

Reply via email to