Operating System - HP-UX
1838703 Members
3079 Online
110128 Solutions
New Discussion

Re: Peculiar Custom LP Spooler Script Problem

 
Clay Jordan
Advisor

Peculiar Custom LP Spooler Script Problem

A custom lp script performs the following functions:

if [ ! -d ${SOME_AREA}/${USER} ]
then
mkdir ${SOME_AREA}/${USER}
mkdir ${SOME_AREA}/${USER}/backup
chgrp -R groupX ${SOME_AREA}/${USER}
chmod 775 ${SOME_AREA}/${USER}
fi

Running as a spooled job (i.e the lp user), the script can create the dirs and chmod them but not change the group. If I run this script as lp from the shell, it can. I added some entries to log what was happening notably

echo "$?" >> ${SOME_AREA}/${USER}/errors
and
whoami >> ${SOME_AREA}/${USER}/errors

These show that it is execing as the "lp" user and that there and it returns 1 for the error. Of course, lp is a member of groupX but it is not its primary group. Any ideas ?
2 REPLIES 2
RAC_1
Honored Contributor

Re: Peculiar Custom LP Spooler Script Problem

After mkdir ${SOME_AREA}/${USER}/backup

do

newgrp "groupX" -- This make lp's primary group - groupx
chmod statement
newgrp "xx" (lp's original primary group)

Anil

There is no substitute to HARDWORK
Clay Jordan
Advisor

Re: Peculiar Custom LP Spooler Script Problem

The newgrp command was a good idea but id did not work. Interestingly, I ran newgrp just before the end of the if-then tree followed by an "echo $? > /../errors" and the lp script ran up only to the newgrp command and bombed out not showing the error but the print job was deleted anyway. Below is a test script which works as explained previously except for chgrp groupX. This was added as a printer using 'lpshut; lpadmin -p nowork -i/tmp/nowork.sh -v/dev/null;lpsched'

#!/usr/bin/sh

JOBID=$1
USER=$2
TITLE=$3
COPIES=$4
OPTIONS=$5
OPT=$6


SOME_AREA=/tmp

if [ ! -d ${SOME_AREA}/${USER} ]

then

mkdir ${SOME_AREA}/${USER}
echo "Err $? #1" >> ${SOME_AREA}/${USER}/errors
mkdir ${SOME_AREA}/${USER}/backup
echo "Err $? #2" >> ${SOME_AREA}/${USER}/errors
chgrp -R ematrix ${SOME_AREA}/${USER}
echo "Err $? #3" >> ${SOME_AREA}/${USER}/errors
chmod 775 ${SOME_AREA}/${USER}
echo "Err $? #4" >> ${SOME_AREA}/${USER}/errors
whoami >> ${SOME_AREA}/${USER}/errors
# next 2 lines were rec. test
newgrp groupX
echo "Err $? #5" >> ${SOME_AREA}/${USER}/errors # never makes it to file

fi

exit 0