awk UNIX

friends because I get this error when calling awk

awk: 0602-546 Can not find or open file estdistica.awk.

Show your command line and start using code tags as explained in the PM you got when doing so, thanks.

friends because I get this error when calling awk
please!!!

awk: 0602-546 Can not find or open file estdistica.awk.

I'll take a wild guess that the error probably means exactly what it says... That it can't find the file. Or, possibly, can't open it.

So think about that a little. What does that mean? Why might it not be able to find the file?

  • Where is the file?
  • How is your script run, from where? What is its current directory?
  • How is awk being called? awk ... -f something what is the <something>? What is the entire line, really?

etc.

Troubleshooting "can't open it":

  • What are its permissions? ls -l estdistica.awk

Please start answering the obvious questions.

this is what I have

valida_cab_det.sh(File contended)

awk -f estdistica.awk < /home/aptcam1/shell/$1 >> /home/aptcam1/shell/Estaditica$1.txt

estadistica.awk ((File contended)

BEGIN {
        #VARIABLES PARA CARGOS

        cargo_sum=0;
        saldo_sum=0;
        trafico_sum=0;
        total=0;


        #variable para no contar la cabecera
        cat=0;

      }
     {
        if (cat != 0)
        {
                #RESCATO LA SUMATORIA DE LOS REGISTRO
                if (substr($0, 20,1) =="1" )
                {
                        # Genera Cabecera
                        cargo_sum=cargo_sum+1;
                        total_cabecera=substr($0, 1,157);
                        printf ("%s\n",total_cabecera);
                }

        }
        cat=1;

      }
END
{
}





Is that one file, two files, or three files? Which is which?

Please answer all my questions which you didn't answer from post #4, too.

so is this look

file 1: valida_cab_det.sh
awk-f estdistica.awk </ home / aptcam1 / shell / $ 1 >> /home/aptcam1/shell/Estaditica$1.txt
 
file 2:estadistica.awk 
BEGIN 
    {
        #VARIABLES PARA CARGOS

        cargo_sum=0;
        saldo_sum=0;
        trafico_sum=0;
        total=0;


        #variable para no contar la cabecera
        cat=0;

      }
     #{
      #  if (cat != 0)
       # {
                #RESCATO LA SUMATORIA DE LOS REGISTRO
                #if (substr($0, 20,1) == "1" )
                #{
                        # Genera Cabecera
                 #       cargo_sum=cargo_sum+1;
                  #				  total_cabecera=substr($0, 1,157);
                   #     printf ("%s\n",total_cabecera);
                 # }

       # }
        #cat=1;

      #}
END 

to execute the file 1 ( valida_cab_det.sh) gives the following error: awk: 0602-546 Can not find or open file estdistica.awk.

Please answer all my questions which you didn't answer from post #4.

If you missed them:

  • Where is the file?
  • How is your script run, from where? What is its current directory?
  • What do you see when you run ls -l estdistica.awk ? This will show its file permissions. Perhaps it's set unreadable.

Please do not retype, you are making a huge amount of errors. Copy-paste.

In the awk command you call 'estdistica.awk' but the file name (File 2) you called it 'estadistica.awk'

I'm not sure if one or the other is a typo or not but I thought I'd point it out.

1 Like

thanks as I saw that little detail was just that nothing more !!!!

1 Like

So the awk command in the script valida_cab_det.sh cannot find or open the file estdistica.awk

Clearly the error comes from the command awk, so at least the awk command can be found, and the script valida_cab_det.sh is running so we clearly found that file at some point as well.

So the problem seems to be that the file estdistica.awk cannot be found or opened by the awk command, when run from the script valida_cab_det.sh from some unknown user and environment.

How is awk supposed to find the file estdistica.awk?
Where is the file estdistica.awk?
And for that matter where is the script valida_cab_det.sh?

Does the user have access to read (open) the file estdistica.awk?
Does the user or environment the script is running in have any idea where estdistica.awk is?

Think you might have a path problem.

HTH