루프의 각 공급업체에 대한 열을 합산하려고 합니다. 나의 모호함에 대해 사과드립니다. 최선을 다해 설명하겠습니다. 공급자 이름 합계를 기반으로 각 공급자에 대한 파일에서 위치 10의 할인_금액 필드를 읽는다고 가정합니다. 스크립트를 실행하면 expr: non-numeric argument
할인 금액이 십진수라는 메시지가 표시됩니다. 다음은 오류를 실행하고 수신하는 스크립트의 일부입니다.
############################################################################
#THIS SECTION WILL CAT THE FILE CREATED IN THE PREVIOUS STEP AND SEARCH THE
#SORTED FILE FOR LIKE VENDORS. THE VENDOR E-MAIL ADDRESS IS ALSO RETREIVED
#HERE AS IT IS AT THE END OF EACH RECORD. WHILE THE VENDOR REMAINS THE SAME,
#A NEW FILE IS CREATED WITH FIRST A COLUMN HEADING LINE, FOLLOWED BY THE DETAIL
#DATA FOR THE VENDOR. ONCE THE VENDOR CHANGES OR END OF THE FILE IS REACHED,
#THE PERL SCRIPT 'emailit.pl' IS USED TO SEND THE ILE TO THE VENDOR AS AN E-MAIL
#ATTATCHMENT. #6 and #7 determined not needed - 12/11/2015
# 1 vendor id 2 vendor name 3 invoice id 4 invoice date 5 invoice id 6 voucher id
# 7 payment id ref 8 payment date 9 paid amount 10 discount amount 11 backhaul freight
#12 gross amount 13 srd deduction 14 srd percent 15 emailid
#16 invoice period end date (maximum of 70 characters must be separated by ;
#############################################################################
#for test
export VENDOR_TEMP=/oracle/rdbms/usr/xxxxxx/scripts/temp/
echo "VENDOR_ID,VENDOR_NAME,INVOICE_ID,INVOICE_DATE,SCH_INVOICE_ID,PAYMENT_DATE,PAID_AMT,DISCOUNT_AMT,SCH_BACKHAUL_FRGHT,GROSS_AMT,DEDUCTION_AMT,SRD_PERCENT,EMAILID" > VENDOR_HDR
cat $VENDOR_FILE | while read LINE
do
VENDOR_NAME=`echo $LINE | awk -F, '{print $2}'`
touch $VENDOR_TEMP/$VENDOR_NAME
echo $LINE >> $VENDOR_TEMP/$VENDOR_NAME
done
VENDOR_LIST=`ls $VENDOR_TEMP`
echo "if there is a vendor with two or more entries in the vendor list file you may see a mv statement that states cannot access: No such file or directory" | tee -a $Log
for VENDOR_NAME in `echo $VENDOR_LIST`
do
DISCOUNT_TOTAL=0
INVOICE_DATE=''
VENDOR_ID=`awk -F, 'NR==1{print $1}' $VENDOR_TEMP$VENDOR_NAME`
EMAIL_ADDRESS=`awk -F, 'NR==1{print $15}' $VENDOR_TEMP$VENDOR_NAME`
INVOICE_NUMBER=$(awk -F, 'NR==1{print $16}' $VENDOR_TEMP$VENDOR_NAME)
# Read each line of the vendor file to get the invoice date and sum invoice totals
for f in $(cat $VENDOR_TEMP$VENDOR_NAME)
do
DISCOUNT_TOTAL=$(expr ${DISCOUNT_TOTAL} + $(echo $f | awk -F, '{print $10}'))
done
cat VENDOR_HDR $VENDOR_TEMP$VENDOR_NAME > VENDOR_TMP
mv VENDOR_TMP $VENDOR_TEMP$VENDOR_NAME
mv $VENDOR_TEMP$VENDOR_NAME $VENDOR_TEMP$VENDOR_NAME.csv
if [ "$EMAIL_ADDRESS" = '' ];then
./send_email.pl --sub "INVALID EMAIL ADDRESS PLEASE CORRECT $VENDOR_ID $VENDOR_NAME" --rec 'emailaddresses' --file "$VENDOR_TEMP$VENDOR_NAME.csv" --total $DISCOUNT_TOTAL --date $INVOICE_DATE --invoice $INVOICE_NUMBER
else
./send_email.pl --sub "$VENDOR_ID $VENDOR_NAME Schnuck Retail Deductions (SAS)" --send emailaddresses.com --rec [email protected] --file "$VENDOR_TEMP$VENDOR_NAME.csv" --total $DISCOUNT_TOTAL --date $INVOICE_DATE --invoice $INVOICE_NUMBER
fi
mv $VENDOR_TEMP$VENDOR_NAME.csv $SCH_ARCHIVE/$(basename $VENDOR_TEMP$VENDOR_NAME.csv).$FILEDATE
done
다음은 읽고 있는 데이터의 예입니다.
122198,ConAgra_Foods_Co,SRD122198032915,16-MAR-15,0450287,25146609,213199,27-MAR-15,3767.01,77.77,0,3844.78,0,0,emailaddress.com,29-NOV-15
140214,Joy_Cone__Co,SRD140214032915,04-MAR-15,243395,25104588,212317,18-MAR-15,2971.16,60.64,0,3031.8,0,0,emailaddress.com;,29-NOV-15
140214,Joy_Cone__Co,SRD140214032915,04-MAR-15,243394,25104587,212317,18-MAR-15,2363.76,48.24,0,2412,0,0,emailaddress.com,29-NOV-15
147810,McCormick_Company,SRD147810032915,10-MAR-15,3784260,25143679,100141,18-MAR-15,17446.63,356.09,0,17802.72,0,0,emailaddress,29-NOV-15
147810,McCormick_Company,SRD147810032915,03-MAR-15,3777825,25112108,099510,11-MAR-15,4913.94,100.3,0,5014.24,0,0,emailaddress,29-NOV-15
147810,McCormick_Company,SRD147810032915,27-FEB-15,3775282,25098526,099330,09-MAR-15,7269.84,148.36,0,7418.2,0,0,emailaddress,29-NOV-15
147810,McCormick_Company,SRD147810032915,26-FEB-15,3773988,25098525,099155,06-MAR-15,4611.8,94.12,0,4705.92,0,0,emailaddress,29-NOV-15
147810,McCormick_Company,SRD147810032915,24-FEB-15,3770586,25081388,098931,04-MAR-15,9742.03,198.83,0,9940.86,0,0,emailaddress,29-NOV-15
159605,Nestle_Waters_of_North_America,SRD159605032915,18-JAN-15,4296435,24908423,210015,04-MAR-15,8772.68,0,0,8772.68,0,0,emailaddress,29-NOV-15
159605,Nestle_Waters_of_North_America,SRD159605032915,19-JAN-15,4397088,24908424,210015,04-MAR-15,5148,0,0,5148,0,0,emailaddress,29-NOV-15
답변1
귀하의 질문은 모호함과 불완전성으로 인해 거의 대답할 수 없는 상태로 남아 있습니다. 입력 데이터(요청한 대로)나 코드(요청한 대로)를 표시하지 않았습니다. 그러나 다음과 같은 정보가 유출되었습니다.
++ expr 0 + 496.8
expr: non-numeric argument
expr
정수가 아닌 숫자(예: 소수점이 있는 숫자)에는 작동하지 않습니다. 데이터를 정수로 변환하거나 정수가 아닌 값을 처리하는 계산기 프로그램을 사용해야 합니다( bc
이것이 좋은 접근 방식입니다).