autosysjil

Autosys - Get Jobs list on a specific computer


I try to get the list of all the jobs running on a specific client.

When running autorep -J ALL -q I get the following output:

 /* ----------------- ### ----------------- */

  insert_job: ###   job_type: CMD
  box_name: ###
  command: ###
  machine: MACHINE X
  owner: autosys
  permission:
  date_conditions: ###
  condition: ###
  description: ###
  box_terminator: 1
  alarm_if_fail: 0
  application: ###


  /* ----------------- ### ----------------- */

  insert_job: ###   job_type: CMD
  box_name: ###
  command: ###
  machine: MACHINE Y
  owner: autosys
  permission:
  date_conditions: ###
  condition: ###
  description: ###
  box_terminator: 1
  alarm_if_fail: 0
  application: ### 

  ...

As you can see, is displayed here the list of ALL the jobs for ALL the clients

What I expect to get is an output as following :

 /* ----------------- ### ----------------- */

  insert_job: ###   job_type: CMD
  box_name: ###
  command: ###
  machine: MACHINE X
  owner: autosys
  permission:
  date_conditions: ###
  condition: ###
  description: ###
  box_terminator: 1
  alarm_if_fail: 0
  application: ###


  /* ----------------- ### ----------------- */

  insert_job: ###   job_type: CMD
  box_name: ###
  command: ###
  machine: MACHINE X
  owner: autosys
  permission:
  date_conditions: ###
  condition: ###
  description: ###
  box_terminator: 1
  alarm_if_fail: 0
  application: ### 

  ...

Unfortunately the commands autorep -J ALL -q -m MACHINE X doesn't work but give me the following output :

/* ----------------- MACHINE X ----------------- */

insert_machine: MACHINE X
type: a
factor: 1.00
port: 7520
node_name: MACHINE X
agent_name: WA_AGENT
encryption_type: DEFAULT
opsys: windows
character_code: ASCII

I guess that this is the JIL format to add a machine, so what no I expect to get.

Do you know if what I try to do is possible using autosys commands only or if I have to parse the first output trough some regex to finally obtain what I would like to ?


Solution

  • I have finally created a script that does it for me :

    #!/bin/ksh
    autorep -j ALL -q > alljobs.jil
    mkdir /tmp/autosystemp
    i=0
    while IFS=\| read -r "line"; do
            if [ `echo $line | grep '/* ------' | wc -l` -eq 1 ]; then
                    i=$((i+1))
            fi
            echo "$line" >> "/tmp/autosystemp/f$i"
    done < alljobs.jil
    rm tempo/f0
    for file in /tmp/autosystemp/*; do
            while read line; do
                    if [ `echo $line | grep "machine: $1" | wc -l` -eq 1 ]; then
                            cat $file >> "jobs-on-$1.jil"
                    fi
            done < $file
    done
    rm -rf /tmp/autosystemp
    

    To use it just pass the machine name as an argument to the script