Scripting problem

I'm hoping one of you scripting experts can help me.
I'm trying to find out the IP Address of every printer on my HP-UX server. (There's 256 of them)
I'm trying to do it using the PERIPH= value in /etc/lp/interface/<printername>, but I'm having problems scripting it as I'm a bit of a newbie.

I think I know what to do, I just can't work out how.

cd /etc/lp/interface
ll | awk `{ print $9 }` >> /tmp/printers #This will give me the printer names
PRINTERS=`cat /tmp/printers
cat /tmp/printers | wc -l >> /tmp/printnumber #This will give me the number of printers
NUMBER=`cat /tmp/printnumber`

I then want to:

grep for the expression PERIPH= in /etc/lp/interface/* and echo this out to another file, listing the printername and the value of PERIPH= only. What the easiest way of telling it to execute the grep and redirect, $NUMBER of times? :confused: I hope that's clear.

Can anyone help?

#! /usr/bin/ksh
cd /etc/lp/interface
count=0
for i in * ; do
        if [[ -f $i ]] ; then
                x=$(grep "^PERIPH=" $i)
                x=${x#PERIPH=}
                echo $i $x
                ((count=count+1))
        fi
done
echo $count total printers
exit 0

Spot on Perderabo Thanks!!!!! :slight_smile: