Computing.Net > Forums > Unix > korn shell script problem (using awk ? )

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.

korn shell script problem (using awk ? )

Reply to Message Icon

Name: Balaji
Date: July 26, 2002 at 11:55:47 Pacific
Comment:

hi ,
I have a problem in Korn shell script(in dtksh)

my program is like that......

#!/usr/dt/bin/dtksh
awk '
BEGIN {
FS = ":";
# print '$1','$2','$3'
cmdargs = '$#'
}
{
if( cmdargs == 3)
{ if( ($5 > '$2' && $5 < '$3') && ($1 ~ /'$1'/) )
printf("%-10s %-15s %4d %5d %10d\n",\
$1,$2,$3,$4,$5) | "sort -k 5,5n"
}
if( cmdargs == 1)
{ if( $1 ~ /'$1'/ )
printf("%-10s %-15s %4d %5d %10d\n",\
$1,$2,$3,$4,$5) | "sort -k 5,5n"
}
} ' cars

and data file is like this .....

ford:mustang:77:73:2500
volvo:gl:78:102:10000
plym:fury:77:73:2500
chevy:nova:79:60:3000
chevy:nova:80:50:5500
fiat:600:65:115:450
honda:accord:81:30:6000
toyota:tercel:82:180:750

-----
my problem is when i put the three commandline arguments it will execute correctly...but if u put one commandline argument it gives an error.
I don't know why it comes like that.
can u please clarify me...
i given commandline args like this and see the errors also...

$ show_car2.ksh chevy 1000 6000
chevy nova 79 60 3000
chevy nova 80 50 5500
$ show_car2.ksh chevy
awk: syntax error near line 9
awk: illegal statement near line 9

I executed this script in dtksh shell...
please help asap...
thank you very much
bye
- balaji



Sponsored Link
Ads by Google

Response Number 1
Name: Tim
Date: July 27, 2002 at 21:14:16 Pacific
Reply:

I see your problem, and have all the answers!

Unfortunately I can't tell you.

Sworn oath, ya see


0

Response Number 2
Name: Frank
Date: July 29, 2002 at 02:41:58 Pacific
Reply:

I got the fault too.

But you can be sure I will not answer to a A.S.A.P. request.

Somtimes my boss told me to do scripting A.S.A.P, that's ok because he is paying for that.

Here a hint:
Anyway there are more than only one fault in this script. (Also from the logical point of view)

But regarding to your error you have to thing about the values of the shell arguments.

No RISK no fun
Frank


0

Response Number 3
Name: Ned
Date: July 29, 2002 at 12:34:27 Pacific
Reply:

Are you still looking for the solution, including sorting?



0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


perl script - record alte... BIND on Solaris *



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: korn shell script problem (using awk ? )

sftp Korn shell script www.computing.net/answers/unix/sftp-korn-shell-script/4741.html

korn shell script help www.computing.net/answers/unix/korn-shell-script-help/3815.html

can an FTP Korn Shell Script be written www.computing.net/answers/unix/can-an-ftp-korn-shell-script-be-written/3569.html