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

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

awk variables in shell script

Reply to Message Icon

Name: xoir
Date: April 29, 2004 at 09:08:13 Pacific
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



Sponsored Link
Ads by Google

Response Number 1
Name: Wolfbone
Date: April 29, 2004 at 12:11:59 Pacific
Reply:

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.


0

Response Number 2
Name: xoir
Date: April 29, 2004 at 12:44:06 Pacific
Reply:

=') ok, it works thanks for the advise

Best Regards,
RRV


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: awk variables in shell script

use variable of shell script in awk www.computing.net/answers/unix/use-variable-of-shell-script-in-awk/4570.html

Variables in Shell SCripting www.computing.net/answers/unix/variables-in-shell-scripting/6020.html

Parameter file for a shell script www.computing.net/answers/unix/parameter-file-for-a-shell-script/6026.html