Archive for the ‘AIX’ Category

aix printer backend (recover file name)

Thursday, August 25th, 2016

#!/bin/ksh
#
# AIX queuing system backend for SMS processing
#
# This AIX queuing system backend is used in the conversion
# of McDonalds SMS files to HR-Access
# It performs the following tasks
# – Recovers the original filename of the SNS file
# from the queuing system control file
# – Copies the file to a spooling location with its original name
# – Resubmit the job to the final processing queue with new user
# (depends on sudo being correctly configured)
#
# Created: 18.10.06 Markus Baertschi, IBM
#
#

# recover the environment from the path where the file is stored
# example: /home/hrprd/bin/smsbak.sh -> prd
HRENV=$(dirname $0)
HRENV=${HRENV#/home/hr}
HRENV=${HRENV%/bin}
# define sone of the variables we use
HRUSER=”hr$HRENV”
SMSDIR=/var/sms/$HRUSER
HRQUEUE=”sms$HRENV”
NQUEUE=${HRQUEUE}2
LOG=/var/log/$HRUSER/smsbak-sh.log

# write all output to the logfile
exec 2>&1 >> $LOG

echodate () {
echo “$(date +’%d.%m.%y %H:%M:%S’) $*”
}

echo “=========== smsbak.sh ===============”
echodate “Args: $*”
echodate “User: $HRENV/$HRUSER/$HRQUEUE Id:$(id)”

FNAME=”$1″
echo “Spooled file name: $FNAME”

#
# Search for the control file of my job
#
CFILE=$(grep -l “$FNAME” /var/spool/lpd/qdir/*)
if [ -z “$CFILE” ]
then
print “Error: control file for $1 not found”
echo “!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!”
exit 1
fi
#
# Extract the original filename from the control file
#
JNAME=$(awk -F”\-[TB]” ‘/\-T/{print $2;}’ “$CFILE”)
if [ -z “$JNAME” ]
then
print “Error: job name in ‘$CFILE’ not found”
echo “!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!”
exit 1
fi

echodate “Extracted Job name: $JNAME”
#
# Copy the job file to a spool directory (to be created if necessary)
# and change its owner to the target user
#
mkdir -p $SMSDIR
cd $SMSDIR
cp $FNAME $JNAME
sudo chown $HRUSER $JNAME
ls -l $JNAME

#
# Re-submit the file to the SMS processinq queue Inflatables Quality using the target user
#
CMD=”enq -P $NQUEUE -T $JNAME $SMSDIR/$JNAME”
echo sudo su – $HRUSER -c $CMD
sudo su – $HRUSER -c $CMD

lpstat -psmsprd
echo “———– smsbak.sh ———–“

Basic ksh configuration

Monday, January 1st, 2007

The AIX command line, as shipped by IBM, has no comfort whatsoever. This is unfortunate as it is easy to add some basic stuff to make life much easier. Here what I install on a new AIX box as soon as possible.Inflatable Water Slide

(more…)