Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Command line variables as input to AWK?

Status
Not open for further replies.

AwkNewbie

Programmer
Nov 12, 2002
4
US
The following program works fine, EXCEPT I get residue on the screen. I appear to me as the command line variables being passed to AWK:

Program below:


#!/usr/bin/ksh

#===========================================================
# Needed for CRON (refreshes profile)...
#===========================================================
conORACLE_SID=`/usr/ucb/whoami | tr '[:lower:]' '[:upper:]'`

. /opt/clarify/$conORACLE_SID/.profile

#===========================================================
# Declarations...
#===========================================================
conCOMMAND_DIRECTORY="/usr/xpg4/bin"
strTimeStamp=`date '+_%y%m%d_%H:%M:%S'`
strINPUT_FILE="/opt/clarify/$conORACLE_SID/$1/log_files/stress/stress_$1.txt"
strOUTPUT_FILE="/tmp/stress_$1$strTimeStamp.txt"

$conCOMMAND_DIRECTORY/awk -v output_file=$strOUTPUT_FILE '
BEGIN {
x = 1
}
{
if (substr($0,1,1) == "\"")
{
print $0 > output_file
}
else
{
if (x > ARGV[2])
{
print $0 > output_file
}
x++
}
}
' $strINPUT_FILE $2


Output from program:

/opt/clarify/scripts[CRMS]:-> strrefresh1.ksh cntc_rxr 10
input file "10"/opt/clarify/scripts[CRMS]:->

My question is, where does the text (input file "10") come from?

Thanks
 
Could it be coming out of your .profile file? Put some echo statements before and after the .profile call and the awk call to narrow down the source of the extraneous output. CaKiwi
 
I commented out the .profile line and I still got the same results. I will investigate it further...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top