Reputation: 2410
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 ?
Upvotes: 3
Views: 6166
Reputation: 2410
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
Upvotes: 0
Reputation: 34
I have created a Autosys Jill parser , using that you can have required info in csv file .After that you can filter required information
first you must have a file which contains required columns to be extracted from jill like
$]cat Jill_Columns
insert_job
job_type
box_name
watch_file
watch_interval
command
date_conditions
machine
owner
permission
condition
days_of_week
exclude_calendar
start_times
description
std_out_file
std_err_file
alarm_if_fail
profile
application
and Jill file which needs to be parsed to csv
Here is the script
Command to run in unix box
sh JillToCsv.sh Your_Jill_Columns Yours_Jill_file
#!/bin/bash
Usage()
{
echo "----------------------------------------------------------------------------"
echo " "
echo " "
echo " "
echo "This script takes two parameter "
echo "First is the file which conatins column names like below for Jill information "
echo "cat Jill_ColumnOrder.txt"
echo "insert_job
job_type
box_name
command
date_conditions
machine
owner
permission
condition
days_of_week
exclude_calendar
start_times
description
std_out_file
std_err_file
alarm_if_fail
profile
application"
echo " "
echo " "
echo " "
echo "Second is the Jill File which needs to be parsed as csv "
echo " "
echo " "
echo " "
echo "----------------------------------------------------------------------------"
}
if [ $# -eq 2 ]
then
echo "File which contains column names : $1"
echo "Input Jill File : $2"
else
echo "Please pass manadatory parameters"
Usage
exit 1
fi
Jill_ColumnOrder=$1
tfile=$2
dos2unix $tfile
final=${tfile}_Parse.csv
rm -f $final
heading=`cat $Jill_ColumnOrder|sed 's/$/@Akhilesh@/g'|sed '$ s/@Akhilesh@$//g'|tr -d '\n'`
line=
filler=1
no_columns=`cat $Jill_ColumnOrder|wc -l`
while [ $filler -lt $no_columns ]
do
filler=`expr $filler + 1`
line=$line`echo -n "@Akhilesh@"`
#echo $line
done
#echo "$heading"
#echo " "
#echo "$line"
echo "$heading">$final
count=1
cat $tfile|sed -r 's/job_type/\njob_type/g'|sed '/^$/d'|sed -r 's/\s+/ /g'|while read kk
do
echo "$kk"|sed -r 's/^[ ]+//g'|grep '\/\* -----------------' # >/dev/null
if [ $? -eq 0 ]
then
count=`expr $count + 1`
echo "$line">>$final
else
PP=`echo $kk|cut -d ':' -f1|tr -d ' '`
#echo "PP : $PP"
val=`echo $kk|cut -d ':' -f2-|sed -r 's/^[ ]+//g'|tr -d '"'|tr -d '\n'`
#echo $val
val=\"$val\"
field=`grep -nw $PP $Jill_ColumnOrder|cut -d':' -f1|tr -d '\n'`
#echo "field : $field"
if [ -z $field ]
then
echo "$PP not there in column list"
else
awk -F'@Akhilesh@' -v OFS=@Akhilesh@ -v var="$val" -v var1=$count '{if(NR== var1) $'$field' = var;print}' $final > tmp.parse && mv tmp.parse $final
fi
fi
done
cat $final|sed 's/@Akhilesh@/,/g' > tmp.parse && mv tmp.parse $final
Upvotes: 1
Reputation: 208
autorep does not support that sorting as of yet. You will need to parse out the output.
Dave
Upvotes: 0