how can i combine the following two scripts into one:
second script:
here i deleted a printer name and recreated printer
Code:
#!/bin/ksh
BIN=/usr/lbin
LINE='device for 0101a01: lpd://172.25.41.111:515'
while read LINE
do
prt=`echo $LINE | awk '{print $3 }'| cut -c 1-7`
echo $prt
#drv=`echo $LINE | awk -F":" '{print $2}'`
#echo $drv
#IP=`echo $LINE | awk -F"/" '{print $3}' | cut -d":" -f1`
#echo $IP
#port=`echo $LINE | awk -F":" '{print $4}'`
#echo $port
if [ "${prt}" = "0117bd1" ]; then
echo "\n\t Deleting printer $prt !!!"
$BIN/lpadmin -x ${prt} 2> /dev/null
fi
done < diffs.txt
second script:
Code:
#!/bin/ksh -xv
BIN=/usr/lbin
LINE='device for 0101a01: lpd://172.25.41.111:515'
while read LINE
do
prt=`echo $LINE | awk '{print $3 }' | cut -c 1-7`
echo $prt
drv=`echo $LINE | awk -F":" '{print $2}'`
echo $drv
IP=`echo $LINE | awk -F"/" '{print $3}' | cut -d":" -f1`
echo $IP
port=`echo $LINE | awk -F":" '{print $4}'`
echo $port
if [ "${prt}" = "0117bd1" ]; then
echo " Adding printer $prt !!!!"
$BIN/lpadmin -p ${prt} -E -v ${drv}://${IP}:${port}
echo " Printer $prt:$drv:$IP:$port added!!!!"
fi
done< diffs.txt
here i deleted a printer name and recreated printer