![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| ftp errors | Approx.Purified | UNIX for Dummies Questions & Answers | 1 | 02-15-2008 04:06 PM |
| Major OS errors/Bash errors help!!!! | wcmmlynn | UNIX for Dummies Questions & Answers | 12 | 11-13-2007 01:50 AM |
| Adapter Errors and Link Errors | mcastill66 | AIX | 2 | 08-02-2005 03:51 PM |
| Adapter Errors and Link Errors | mcastill66 | UNIX for Advanced & Expert Users | 0 | 08-02-2005 03:11 PM |
| awk errors | billy5 | Shell Programming and Scripting | 4 | 06-22-2005 03:30 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
AWK Syntax errors :/
I recently started as an intern and my manager wanted to see how well I would handle Korn Bourne shell scripting without any prior experience, I have prior programming experience but I keep running into syntax errors with AWK. Please take a look at my simple code and tell me what stupid mistake I'm doing.
From Telnet: awk -F, -f app_kpi_001.pgm test_file.csv awk: syntax error near line 1 awk: bailing out near line 1 Contents of app_kpi_001.pgm: BEGIN { FS="," } $1 ~ /PBR/ { print $1 } END { print "Done" } This script itself is useless, I'm trying to play around with it so that I'm familiar with it. I have this CSV file which I will have to take as the input and create some pretty lengthy and complicated operations on between BEGIN and END to monitor key performance indicators. Any help is greatly appreciated as I'm new and eager to learn. There is no training here (which is what I thought they'd give me since I'm an intern). |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
if on Solaris, try using 'nawk' instead of 'awk'.
|
|
#3
|
|||
|
|||
|
Hmm...
I just asked someone on the floor if the server is on Solaris, and yes it is. Here's the result of using nawk instead of awk.
From Telnet: nawk -F, -f app_kpi_001.pgm test_file.csv nawk: syntax error at source line 1 context is <<< BEGIN { FS="," >>> } nawk: bailing out at source line 1 Content of app_kpi_001.pgm: BEGIN { FS="," } $1 ~ /PBR/ { print $1 } END { print "Done" } Is there something obviously wrong with my code? Hmm.. I have the "UNIX in a NUTSHELL" book in front of me which I've been reading since yesterday, it has Korn and Bourne shell chapter and I've also been googling around for awk syntax since yesterday hm. Last edited by yongho; 06-08-2005 at 10:39 AM. |
|
#4
|
||||
|
||||
|
works just fine on Solaris 8
Make sure you have no hidden control characters anywhere in the file - in particular the first line. |
|
#5
|
|||
|
|||
|
ah... Hmm..
Thank you for checking for me.
Now that I know that the code works, I'm looking elsewhere for the cause of error. I've been using a program on Windows called Editplus, it's supposed to be plain TXT and nothing else. And I've just been uploading that file to the server via FTP. I thought at first it might be because maybe editplus was using "hard" tabs, but I switched them to "soft" tabs.. I'll try to see if I can find any hidden characters that may be screwing with the code. |
|
#6
|
||||
|
||||
|
make sure you ftp to Sun in 'ascii' mode.
|
|
#7
|
|||
|
|||
|
You're absolutey right.
That was the cause of the problem. I VI'ed the file and noticed that there was a hidden "^M" character at the end of each line. Switching my ftp client to ascii mode (as opposed to auto mode) fixed the problem. Thank you, I appreciate your help in this time-consuming matter. And now, I can begin coding my assignment, the real hard part begins for me. |
|||
| Google The UNIX and Linux Forums |