LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-01-2009, 10:37 AM   #1
wick3dsunny
LQ Newbie
 
Registered: Jun 2009
Posts: 3

Rep: Reputation: 0
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?
 
Old 06-01-2009, 12:16 PM   #2
fpmurphy
Member
 
Registered: Jan 2009
Location: /dev/ph
Distribution: Fedora, Ubuntu, Redhat, Centos
Posts: 299

Rep: Reputation: 62
I am surprised it ever worked. You need double quotes around your second argument i.e. "(1/1 - 100%)"
 
Old 06-01-2009, 12:24 PM   #3
wick3dsunny
LQ Newbie
 
Registered: Jun 2009
Posts: 3

Original Poster
Rep: Reputation: 0
well, both the arguments passed and (1/1 - 100%) are variables. The second variable was double quoted.
 
Old 06-01-2009, 01:13 PM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
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.
 
Old 06-01-2009, 01:46 PM   #5
wick3dsunny
LQ Newbie
 
Registered: Jun 2009
Posts: 3

Original Poster
Rep: Reputation: 0
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
 
Old 06-01-2009, 02:52 PM   #6
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
checking for intltool >= 0.35.0... awk: cmd. line:1: fatal: cannot open file `./intlt chytraeus Linux - Software 2 12-25-2008 05:08 AM
awk , I need help for awk, just a display function mcandy General 1 12-15-2008 12:21 PM
shell command using awk fields inside awk one71 Programming 6 06-26-2008 04:11 PM
Some comments on awk and awk scripts makyo Programming 4 03-02-2008 05:39 PM
awk: fatal:cannot open file for reading (no such file or Directory) in Linux sangati vishwanath Linux - Software 4 07-06-2005 12:59 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:56 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration