I have never done this type of scripting before. Can someonepoint me in the right direction of how I can manually script it so that I don't have to manually fix the queues each message by message, sometimes there can be hundreds and it can be quite tedious. Thanks!
#!/bin/bash
Command.sh errors | while read line
do
if [[ "$line" =~ ^ID: ]] # Check if line starts with pattern - "ID:"
then
id=${line#ID:} # Remove string - "ID:" from beginning of line
id=${id%%<*} # Remove string - < followed by all chars - "<*"
Command.sh fix "$id" # Run fix script by passing "$id" as argument
fi
done
Thank you for pointing me in the right direction. This is KSH, not sure if it makes a difference but this is the error I am getting.
mqfix.sh[3]: syntax error at line 5 : `=~' unexpected
Heres where I was going and it is not working.
cd /jeff/mq/
var1=`Command.sh fix | awk '{print substr($0,4,48);exit}' '`
echo $var1
if [ -n $var1 ]
then
echo "There are errors on the queue..fixing"
for i in `Command.sh fix | awk '{print substr($0,4,48);exit}' '`
do
Command.sh fix $1
done
fi
#!/bin/ksh
Command.sh errors | while read line
do
if echo "$line" | egrep -q '^ID:'
then
id=${line#ID:} # Remove string - "ID:" from beginning of line
id=${id%%\<*} # Remove string - < followed by all chars - "<*"
Command.sh fix "$id" # Run fix script by passing "$id" as argument
fi
done