LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   awk: cant open (https://www.linuxquestions.org/questions/linux-software-2/awk-cant-open-729876/)

wick3dsunny 06-01-2009 10:37 AM

awk: cant open
 
Hi Guys,



I was just trying to run a bunch of test scripts which ran perfectly before. But i just changed it to run on a different solaris version and my awk statement in the script shows an error.


Code:

awk BEGIN{s=ARGV[1]; r=ARGV[2]; \
                delete ARGV[1]; delete ARGV[2]; \
                printf("%-7s%-17s", s, r); } passed (1/1 - 100%)


Code:

awk: can't open passed


The script worked perfectly before and now it gives an error. I tried copying existing awk and using that but still i get the same error. Can anyone give any suggestions on how to go about this problem?

fpmurphy 06-01-2009 12:16 PM

I am surprised it ever worked. You need double quotes around your second argument i.e. "(1/1 - 100%)"

wick3dsunny 06-01-2009 12:24 PM

well, both the arguments passed and (1/1 - 100%) are variables. The second variable was double quoted.

colucix 06-01-2009 01:13 PM

Maybe did you forgot the single quotes around the awk program? The error means it's trying to open a file called "passed", as if you did not put the BEGIN statement.

wick3dsunny 06-01-2009 01:46 PM

Well my command line is something like this :


Code:

        nawk 'BEGIN{t=ARGV[1]; s=ARGV[2]; r=ARGV[3]; \
            delete ARGV[1]; delete ARGV[2]; delete ARGV[3]; \
            printf("\n%-38s%-7s%-17s", substr(t,1,37), s, r); }' \
            $cur_item $status "$other_var">> $output_file


colucix 06-01-2009 02:52 PM

Hmmm... it works for me on a Solaris Sparc 5.8 using nawk. The syntax looks correct. An aside note: you can use the printf command and shell's parameter substitution (for the substr part) to do the same thing without using awk.


All times are GMT -5. The time now is 09:20 AM.