awk output yields error: awk:can't open job_name (Autosys)


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting awk output yields error: awk:can't open job_name (Autosys)
# 1  
Old 02-04-2015
awk output yields error: awk:can't open job_name (Autosys)

Good evening, Im newbie at unix specially with awk
From an scheduler program called Autosys i want to extract some data reading an inputfile that comprises jobs names, then formating the output to columns for example

1.
This is the inputfile:
Code:
$ more MapaRep.txt
ds_extra_nikira_usuarios
ds_extra_ordenesserv
ds_extra_recargajuste
ds_extra_score_dinamico
ds_ftp_ciclo_migr_05

2. This is the script
Code:
[validate_process
#!/bin/ksh
for i in `cat \home\autosys\MapaRep.txt`
do
  autorep -J $i -q
done]

3. the output is something like listing n jobs name proprties
Code:
/* ----------------- ds_extra_nikira_usuarios ----------------- */ 
insert_job: ds_extra_nikira_usuarios   job_type: c 
box_name: ds_rep_nikira
command: /archivos/Shells/dwhExtraNikiraUsuarios.sh
machine: proetldb01c
owner: dsadm@proetldb01c
permission: gx,wx,mx
date_conditions: 1
days_of_week: all
start_times: "13:00"
alarm_if_fail: 1
max_exit_success: 2

/* ----------------- ds_extra_ordenesserv ----------------- */ 
insert_job: ds_extra_ordenesserv   job_type: c 
box_name: ds_rep_nikira
command: /archivos/Shells/dwhExtraccion.sh ordenesserv
machine: proetldb01c
owner: dsadm@proetldb01c
days_of_week: all
start_times: "12:00"
condition: d(ds_extra_recargajuste) & s(dwh_finalizacion)
description: "Genera el plano hacia nikira ORDENES_SERV_ en /archivos/InputFiles"
alarm_if_fail: 1
max_exit_success: 2

Is is OK up to know but i want to extract some data for each job sorted and formated as below:

Code:
insert_job                   command                                                         machine
ds_extra_ordenesserv: /archivos/Shells/dwhExtraccion.sh ordenesserv proetldb
..
job n name                  /command.sh n                                                server n

So in the loop i added the command

Code:
 [ autorep -J $i -q|awk '{printf("%s ", $1,$2)}' $i]

but it yields an error:

Code:
awk: can't open ds_extra_nikira_usuarios
awk: can't open ds_extra_ordenesserv
awk: can't open ds_extra_recargajuste
awk: can't open ds_extra_score_dinamic

So Ive got some questions:
  1. why Ive got this error
  2. I know the output of autorep command is not tabulated, so its neccessary to debug this output by trimming blanks spaces or sth like that before being proccessed ?
  3. any other sugesstions according to your expertise or knowledege ?

Last edited by Don Cragun; 02-04-2015 at 02:02 AM.. Reason: Add CODE, ICODE, and LIST tags.
# 2  
Old 02-04-2015
1. The error is due to the $i after the awk command, which makes awk try to read a file named accordingly.
2. I don't understand your question, but your awk script won't achive your desired result, even if the errors will be removed. Try instead
Code:
awk     'BEGIN          {HD="insert_job\tcommand\tmachine"
                         print HD
                         MX=split (HD, COLHD)}
                        {gsub (/:/, "")}
         HD ~ $1        {O[$1]=$2}
         /exit/         {for (i=1; i<=MX; i++) printf "%s\t", O[COLHD[i]]
                         printf "\n"
                        }
        '
insert_job    command    machine
ds_extra_nikira_usuarios    /archivos/Shells/dwhExtraNikiraUsuarios.sh    proetldb01c    
ds_extra_ordenesserv    /archivos/Shells/dwhExtraccion.sh    proetldb01c

3. You may want to consider rewriting your script like
Code:
while read i
   do   autorep -J $i -q
   done < \home\autosys\MapaRep.txt | awk ... above script ...

# 3  
Old 02-04-2015
ok thanks a lot for your support

What im trying to do is extract some data for each job from the autorep command as a normailized table with 4 columns as below:

Code:
insert_job(jobname)   command                      machine   days_of_week
ds_extra_ordenesserv: /Shells/dwhExtraccion.sh proetldb   all
..
job n name                  /command.sh n             machine n all

dont know if the above script you kindly post does the desired results as i described ?

Thanks for your help in advanced

Last edited by Don Cragun; 02-04-2015 at 09:28 PM.. Reason: Add CODE tags again.
# 4  
Old 02-04-2015
This is not what you sort of specified in post#1. And, did you try the proposal?
# 5  
Old 02-06-2015
Good afternon, i tested in a script but failed yielding errors:
Code:
awk: syntax error near line 4
awk: illegal statement near line 4
awk: syntax error near line 5
awk: bailing out near line 5






Here is the code

Code:
[autosys@proauto01 :PRO >more testing_v1.sh
#!/bin/ksh
#Validate Definition Autosys
while read i
   do   autorep -J $i -q
   done < /auto/autosys/MapaRep.txt |awk     'BEGIN          {HD="insert_job\tcommand\tmachine"
                         print HD
                         MX=split (HD, COLHD)}
                        {gsub (/:/, "")}
         HD ~ $1        {O[$1]=$2}
         /exit/         {for (i=1; i<=MX; i++) printf "%s\t", O[COLHD[i]]
                         printf "\n"
                        }
        '
]


Thanks for your help in advanced

Last edited by Don Cragun; 02-06-2015 at 02:50 PM.. Reason: Add CODE tags.
# 6  
Old 02-06-2015
Try removing the space between the function names and the following open parenthesis:
Code:
#!/bin/ksh
#Validate Definition Autosys
while read i
do   autorep -J $i -q
done < /auto/autosys/MapaRep.txt |awk     '
         BEGIN          {HD="insert_job\tcommand\tmachine"
                         print HD
                         MX=split(HD, COLHD)
                        }
                        {gsub(/:/, "")}
         HD ~ $1        {O[$1]=$2}
         /exit/         {for (i=1; i<=MX; i++) printf "%s\t", O[COLHD[i]]
                         printf "\n"
                        }
        '

# 7  
Old 02-06-2015
Thanks, i already removed the space between the function names and the following open parenthesis but the error remains:

Code:
awk: syntax error near line 4
awk: illegal statement near line 4
awk: syntax error near line 5
awk: bailing out near line 5
autosys@proauto01 :PRO >


Last edited by Don Cragun; 02-06-2015 at 03:46 PM.. Reason: Add CODE tags again.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk runs and produces output but with error

When I run the awk below, I get an error message awk -v OFS='\t' '$(NF-1)=="Benign" || ($(NF-2) OFS $(NF-1))=="Likely Benign" {$(NF)=$(NF-2) OFS $(NF-1)} {print $0 }' input awk: cmd. line:1: (FILENAME=VUS FNR=8) fatal: attempt to access field -1 input Chr Start End Ref ... (6 Replies)
Discussion started by: cmccabe
6 Replies

2. Shell Programming and Scripting

Awk: Print Error While Redirecting output in multiple Files

Hi, I have a following code in which I am unable to redirect to multiple files. Can anybody please help with some corrections awk -F, '{ if ( substr($1,26,2)=="02" && substr($1,184,14)=="MTSCC_VALFIRST") { array1++ array2++ array3++ } else if (substr($1,26,2)=="03" &&... (4 Replies)
Discussion started by: siramitsharma
4 Replies

3. Shell Programming and Scripting

Awk: can't open error

Hi , In a directory i've the files in the following format pay:year:mon:11789604 pay:year:mon:17675644 --- and i need to get 4th part of the above file name so i used awk command in the below code #!/bin/ksh for test_data in pay* do txt_awk = awk -F':' '{print $4;}' $test_data ... (7 Replies)
Discussion started by: smile689
7 Replies

4. Shell Programming and Scripting

awk question : system output to awk variable.

Hi Experts, I am trying to get system output to capture inside awk , but not working: Please advise if this is possible : I am trying something like this but not working, the output is coming wrong: echo "" | awk '{d=system ("date") ; print "Current date is:" , d }' Thanks, (5 Replies)
Discussion started by: rveri
5 Replies

5. Shell Programming and Scripting

awk - Parsing Autosys JIL

I'm trying to modify the script given in post 7 of the following thread: 146564-need-parse-jil-file-into-excel-file.html. (Sorry, can't post the URL as I don't have enough posts.) The original script is as follows: awk -F ' *_]*: *' 'BEGIN ... (9 Replies)
Discussion started by: GnuScripter
9 Replies

6. Shell Programming and Scripting

Using awk with autosys autorep

Hi, How to get correct field/column from autosys autorep command. I'm using GNU/Linux I'm trying to get the difference of last end and last start and the status (ST). In awk, i get the following excluding the heading part $1 - jobname $2 - Last Start date $3 - Last Start time $4 - Last... (1 Reply)
Discussion started by: bobbygsk
1 Replies

7. Shell Programming and Scripting

awk output error while loop through array

Have built this script, the output is what I needed, but NR 6 is omitted. Why? Is it an error? I am using Gawk. '{nr=$2;f = $1} END{for (i=1;i<=f;i++) if (nr != i) print i, nr }' input1.csv >output1.csvinput1.csv 1 9 3 5 4 1 7 6 8 5 10 6 output1.csv > with the missing line number 6. 6 is... (5 Replies)
Discussion started by: sdf
5 Replies

8. Shell Programming and Scripting

help on awk---- need to assign the output of awk to a variable

hi i want to find the size of a folder and assign it to a variable and then compare if it is greater than 1 gb. i am doin this script, but it is throwing error.... #!/bin/ksh cd . | du -s | size = awk '{print $1}' if size >= 112000 then echo size high fi ERROR : (4 Replies)
Discussion started by: Nithz
4 Replies

9. Shell Programming and Scripting

Parse file using awk and work in awk output

hi guys, i want to parse a file using public function, the file contain raw data in the below format i want to get the output like this to load it to Oracle DB MARWA1,BSS:26,1,3,0,0,0,0,0.00,22,22,22.00 MARWA2,BSS:26,1,3,0,0,0,0,0.00,22,22,22.00 this the file raw format: Number of... (6 Replies)
Discussion started by: dagigg
6 Replies

10. Shell Programming and Scripting

scripting/awk help : awk sum output is not comming in regular format. Pls advise.

Hi Experts, I am adding a column of numbers with awk , however not getting correct output: # awk '{sum+=$1} END {print sum}' datafile 2.15291e+06 How can I getthe output like : 2152910 Thank you.. # awk '{sum+=$1} END {print sum}' datafile 2.15079e+06 (3 Replies)
Discussion started by: rveri
3 Replies
Login or Register to Ask a Question