Computing.Net > Forums > Unix > awk variables in shell script

awk variables in shell script

Reply to Message Icon

Original Message
Name: xoir
Date: April 29, 2004 at 09:08:13 Pacific
Subject: awk variables in shell script
OS: solaris 8
CPU/Ram: ultra 80
Comment:

Hi,
Im trying to set variables in awk script but does not work, I dont know what Im doint wrong, this is my script.

#!/bin/sh
snmp-cpu="`snmpwalk -v 1 -c public -Oqv 10.10.1.1 1.3.6.1.4.1.9.2.1.58.0`"
snmp-tempin="`snmpwalk -v 1 -c public -Oqv 10.10.1.1 1.3.6.1.4.1.9.9.13.1.3.1.3.1`"
snmp-tempout="`snmpwalk -v 1 -c public -Oqv 10.10.1.1 1.3.6.1.4.1.9.9.13.1.3.1.3.2`"

/usr/local/bin/awk -v {OFS=","} \
-v cpu="$snmp-cpu" \
-v tin="$snmp-tempin" \
-v tout="$snmp-tempout" \
'BEGIN {print cpu,tin,tout";"}'

Regards,
RRV


Report Offensive Message For Removal


Response Number 1
Name: Wolfbone
Date: April 29, 2004 at 12:11:59 Pacific
Subject: awk variables in shell script
Reply: (edit)

Avoid using '-' characters in your variable names and don't put {} around OFS="," - it's probably better to put OFS="," in the BEGIN {} statement anyway.


Report Offensive Follow Up For Removal

Response Number 2
Name: xoir
Date: April 29, 2004 at 12:44:06 Pacific
Subject: awk variables in shell script
Reply: (edit)

=') ok, it works thanks for the advise

Best Regards,
RRV


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: awk variables in shell script

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




How often do you use Computing.Net?

Every Day
Once a Week
Once a Month
This Is My First Time!


View Results

Poll Finishes In 3 Days.
Discuss in The Lounge