awk -v in SunOS


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting awk -v in SunOS
# 1  
Old 04-04-2006
awk -v in SunOS

Hi folks

I have a small problem wherein i have to obtain the data for the last 5 minutes from a logfile. I need to schedule this script in the crontab so that it runs every 5 minutes. A sample of the data is as shown

Quote:
03:03: Error:Exception while creating telnet instance for switch HLR3please verify userid,password and IP address
03:15: Error:Exception while creating telnet instance for switch HLR3please verify userid,password and IP address
03:18: Error:Exception while creating telnet instance for switch HLR3please verify userid,password and IP address
03:24: Error:Exception while creating telnet instance for switch HLR3please verify userid,password and IP address
03:28: Error:Exception while creating telnet instance for switch HLR3please verify userid,password and IP address
03:31: Error:Exception while creating telnet instance for switch HLR3please verify userid,password and IP address
03:34: Error:Exception while creating telnet instance for switch HLR3please verify userid,password and IP address
03:36: Link is down
03:37: Error:Exception while creating telnet instance for switch HLR3please verify userid,password and IP address
03:38: Error:Exception while creating telnet instance for switch HLR3please verify userid,password and IP address
03:38: Link is down
03:39: Link is down
03:42: Error:Exception while creating telnet instance for switch HLR3please verify userid,password and IP address
The first field is the hour, second the minute, third field is msg (where : is field separatpr)

i tried using awk which worked on HP-UX systems.
Quote:
hh='date +%H'
mi='date +%M'
pp=`expr $mi-5`
awk -F":" -v "h=$hh" -v "min=$mi" -v "period=$pp" '$1==h && $2 <= min && $2 >= period {print}' filename > outputfilename
Like i said this works on HP-UX but i need to run this on a SunOS system where i get the following syntax error

Quote:
awk: syntax error near line 1
awk: bailing out near line 1
Can anyone please help me out. Is there something that i am overlooking. If not awk, is there any other way to obtain the data that i want?

Thanks in advance
# 2  
Old 04-04-2006
On Sun systems, use nawk. The awk that is supplied is an old version. You can search the site for posts that suggest the same. Like this one.
# 3  
Old 08-14-2008
MySQL Wonderful !!!

Quote:
Originally Posted by blowtorch
On Sun systems, use nawk. The awk that is supplied is an old version. You can search the site for posts that suggest the same. Like this one.
I have been fighting with this one A LOT !
I am VERY grateful for you comment "Blowtorch". Smilie
# 4  
Old 08-14-2008
Hi Blowtorch !

Thanx a bunch for your entry about nawk. I looked for this one for a LOOONG time :-)

Kind regards

JoernH
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

awk variable regexp works in AIX but not in SunOS?

Using awk variables for regular expressions is working for me in AIX. It is failing for me in SunOS. I don't know why. Can someone explain and/or suggest a fix for the SunOS version? Here is a little test script. It runs fine in AIX: $ cat test.ksh #! /bin/ksh print "Executed on OS: $(... (6 Replies)
Discussion started by: charles_n_may
6 Replies

2. Shell Programming and Scripting

array and awk match function in SunOS 5.10

Hi Experts, Need help in writing a shell script in SunOS 5.10. I want to use array but it is not running in SunOs where as it is running in unix. pls help Want to print the alue store in array as below but it is giving error. p=1 p=6 p=15 p=20 for i in 1 2 3 4 do echo ${p} done ... (2 Replies)
Discussion started by: forroughuse
2 Replies

3. Solaris

SunOS 5.6

Hi, I called Sun and they said they no longer sell SunOS 5.6. I desperately need a CD-ROM of the install CD to perform maintenance work on a server. Does anyone know where to get one or know someone who can make me a copy? (2 Replies)
Discussion started by: mojoman
2 Replies

4. Solaris

SunOS 5.8 vs 5.10

Hi, I am bulding a path to open files like this \path\values\file.xxx This path is opened in an IE browser window and opens the file/document I am trying to see. I mean it opens a pdf document or it promps you to "save" or "open" the specific file (if it's a .xml, .doc, .html). I was using... (1 Reply)
Discussion started by: hcibl_javok
1 Replies

5. Solaris

New to SunOS...

...and I'm having an issue with memory usage. I got an alert from our sun management console that the box is at 90% memory usage. I need to know what's eating up the memory as this particular box has 16GB of RAM. (3 Replies)
Discussion started by: bbbngowc
3 Replies

6. Solaris

Any patches for SunOS 5.11?

I need patch against the I_PEEK Local Kernel memory Leak Exploit But i'm unable to find any patches for Solaris 5.11, and smpatch is no longer supported... So, do you have any suggestions how to patch my system? Thanks. (4 Replies)
Discussion started by: static
4 Replies

7. Solaris

Looking for help with SunOS 5.6

Hey all, I've got my hands on 10 SunOS 5.6 SPARCStation 20 machines and I'm looking to get them up and running. They're all in various states of disrepair but I've got them all to a state where the hardware is working and the machine will at least attempt to boot. I've only used Solaris as a... (1 Reply)
Discussion started by: kevpatts
1 Replies

8. Solaris

SunOS 5.4

Hi, I Hope you can help me with my problem. I need to have an installation CD of this version. Is there any site you can recommend that I can download an image of this OS? Thanks and God Bless!!! (6 Replies)
Discussion started by: mr_balodoy
6 Replies

9. UNIX for Advanced & Expert Users

Migration of binary file from Sunos 5.8 to Sunos 5.9

I have compiled binary file using "cc" on SunOS 5.8 and the same binary file i have copied to SunOS 5.9 and it is giving me core dump error.I want to know whether migration of compiled code from lower version to higer version created this problem. how can i solve this problem.I am pasting the core... (1 Reply)
Discussion started by: Arvind Maurya
1 Replies

10. Shell Programming and Scripting

SunOS 5.8

I am loging into a SunOS 5.8 box for the first time. I do not see a .profile file in the home directory. Also on the command line when I type a backspace to correct my typing I get a ^H character. Where and how can I fix this? Thanks in advance (5 Replies)
Discussion started by: jxh461
5 Replies
Login or Register to Ask a Question