1752402 Members
5577 Online
108788 Solutions
New Discussion юеВ

Re: Printer Issue

 
citprabhu
New Member

Printer Issue

Hi Gurus,

I have written a script for enabling printers when it is disabled and i have placed in cron for every 30 minutes to check that.

Please see the script for that.

for i in `cat /sys_script/P_list`
do
printerstatus=`lpstat -p\`echo $i\`|awk {'print $5'}`

if [ $printerstatus!= "enabled" ]
then
enable $i
echo "$i printer is enabled on `date`" >> /var/adm/printer/file_log

fi
done
cp /var/adm/printer/file_log /var/adm/printer/file_old1
cp /var/adm/printer/file_old1 /var/adm/printer/file_old2
cp /var/adm/printer/file_old2 /var/adm/printer/file_old3
cp /var/adm/printer/file_old3 /var/adm/printer/file_old4
cp /var/adm/printer/file_old4 /var/adm/printer/file_old5

exit

But now i am gettin an following error for that.


lpstat: printer "qaz0102s" non-existent
/sys_script/P_list[9]: test: Specify a parameter with this command.
lpstat: printer "BOGA_CC" non-existent
/sys_script/P_list[9]: test: Specify a parameter with this command.
lpstat: printer "CLIF_CC" non-existent
/sys_script/P_list[9]: test: Specify a parameter with this command.
lpstat: printer "CLIF_CC" non-existent
/sys_script/P_list[9]: test: Specify a parameter with this command.
lpstat: printer "CLIF_CC" non-existent...

Please see this and do reply since its an urgent issue.
5 REPLIES 5
Dennis Handly
Acclaimed Contributor

Re: Printer Issue

>Please see the script for that.

You need to clean it up:
for i in $(< /sys_script/P_list); do
printerstatus=$(lpstat -p $i | awk '{print $5}')
if [ "$printerstatus" != "enabled" ]; then
enable $i
echo "$i printer is enabled on $(date)" >> /var/adm/printer/file_log
fi
done

In particular use $() vs ```. Replace evil cat.
No need for $(echo $i), just use $i.
But most important is fixing quoting and spacing in that "if". And swapping the single quoting vs {} in awk.
citprabhu
New Member

Re: Printer Issue

Hi,

I followed the above steps as mentioned by you but still i am getting the errors as printers not found.

Please let me know for a script i which to enable a printers if its disabled actually in HP-UX.


Thanks,
Prabhakar.
Dennis Handly
Acclaimed Contributor

Re: Printer Issue

>but still I am getting the errors as printers not found.

I had to clean up -p spacing and look at only the first line:

for i in $(< /sys_script/P_list); do
printerstatus=$(lpstat -p$i | awk '{print $5; exit}')
if [ "$printerstatus" != "enabled" ]; then
enable $i
echo "$i printer is enabled on $(date)" >> /var/adm/printer/file_log
fi
done
citprabhu
New Member

Re: Printer Issue

Thanks alot for the posting it resolved my issue.
Dennis Handly
Acclaimed Contributor

Re: Printer Issue

>Thanks a lot for the posting

If you are happy with the answers you were given please read the following about reopening threads and assigning points:
http://h30499.www3.hp.com/t5/help/faqpage/faq-category-id/kudos#kudos