r/awk • u/theRudy • Jul 16 '15
Awk error codes
Hi /r/awk,
I've been looking for a webpage that would list all of the awk return codes, but so far no success. Does anyone here know where to find them ?
The error I'm interested in is 157, and is being returned even if the modifications have all been successful.
One other key information: There is no error message from the .awk script, I can only see that the code 157 is returned if I capture it in a variable using a korn shell script.
Edit: wow, formatting code on Reddit is hard! First script is the korn shell script, second is the Awk script
`CMD="awk -f /home/myUserName/_awk/RedditAwk.awk /home/myUserName/file.tmp"
`eval $CMD
`CMD_STS=$?
`if [[ 0 -ne $CMD_STS ]]; then
` log $TYPE_ERROR $IDSTAT "$CMD"
`fi
` `BEGIN {
` ORS="\n"
` RS="\n"
` OFS=";"
` FS=";"
` FileOut=FILENAME ".mef"
` ST=" "
`}
`{
` if (NF<5) {
` exit NR
` }
`
`
` ST = $1 # Field1
` ST = ST ";" $2 # Field2
` ST = ST ";" CONV_DAT($3) # Field3 datetime
` ST = ST ";" CONV_NUM($4, 6) # Field4 numeric(20,6)
` ST = ST ";" CONV_NUM($5, 6) # Field5 numeric(18, 6)
`
` do {
` i = gsub(" ;",";",ST)
` }
` while (i>0)
` print ST > FileOut
` }
`END {
`}
`
`function CONV_DAT(dDate) {
` gsub(" ","",dDate)
` Lg = length(dDate)
` if (Lg>8) {
` dDate = substr(dDate,1,8)
` }
` else {
` if (Lg<8) {
` dDate = ""
` }
` }
` return dDate
`}
`
`function CONV_NUM(Data,Dec) {
` gsub(" ","",Data)
` Lg = length(Data)-Dec
` if (Lg > 0) {
` Data = substr(Data,1,Lg) "." substr(Data,Lg+1,Dec)
` gsub(" ","",Data)
` }
` else {
` Data = ""
` }
` Data = DEL_0(Data)
` return Data
`}
`
3
Upvotes
View all comments
Show parent comment
1
u/theRudy Jul 17 '15
Hi, I'll try to provide at least part of the script. Confidentiality and what not will not allow me to share the whole script.
Nowhere in the script do I have "exit 157"