Hammer script to get output from Job by id

This is a simple script I use to export the details from a Job run in Red Hat Satellite 6.2 using hammer from the console.

#!/bin/bash
# Redhat Satellite Job query by id using hammer

if [ $1 -eq $1 ] 2>/dev/null; then
# get hosts run by ID
JOBHOSTS=$(hammer job-invocation info –id $1 | sed ‘1,/Hosts/d’ | awk {‘print $2’} | awk ‘NF’)

# Loop hosts
for HOST in $JOBHOSTS
do
echo “================================================================================
$HOST
================================================================================”
hammer job-invocation output –id $1 –host $HOST
echo “”
done
else
echo “You need to type the Job ID”
fi