Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
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"
}
} ' carsand 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 9I executed this script in dtksh shell...
please help asap...
thank you very much
bye
- balaji

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

![]() |
perl script - record alte...
|
BIND on Solaris *
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |