HPE Community read-only access December 15, 2018
This is a maintenance upgrade. You will be able to read articles and posts, but not post or reply.
Hours:
Dec 15, 4:00 am to 10:00 am UTC
Dec 14, 10:00 pm CST to Dec 15, 4:00 am CST
Dec 14, 8:00 pm PST to Dec 15, 2:00 am PST
cancel
Showing results for 
Search instead for 
Did you mean: 

Trying to reach printers

 
SOLVED
Go to solution
Manuales
Super Advisor

Trying to reach printers

Hi ..
i need to verify if the printers are reachables or not.
i am using ping command.
I know that many of them are not reachables.. but i need to create the evidence.
when i ping them, it takes a long long long tiime ... who can i do to let the ping command know "if you can not reach the printer after 10 seconds, please break and follow the next one" ??? (i am using a shell using for ...)

what other command can i use to test if the printer is reachable or not?

please let me know.
thanks in advance.
Manuales :)
thanks in advance.

14 REPLIES
Patrick Wallek
Honored Contributor
Solution

Re: Trying to reach printers

Have you looked at the ping man page? You can limit the number of packets sent to each name/IP address. When that number of packets has been transmitted, the command will exit.

Consider the following:

# ping -n 3 printer1

will transmit 3 packets to printer 1 and exit.

# pint -n 5 -t 5 printer2

will time out after 5 seconds or 5 packets have been transmitted. The use of '-t' requires the use of '-n'.

See 'man ping' for more information.
Patrick Wallek
Honored Contributor

Re: Trying to reach printers

>># pint -n 5 -t 5 printer2
>>
>>will time out after 5 seconds or 5 packets
>>have been transmitted. The use of '-t'
>>requires the use of '-n'.

I screwed up above. The '-t' should actually be '-m'. The '-t' option is different.

The above should actually read:

# pint -n 5 -m 5 printer2

will time out after 5 seconds or 5 packets have been transmitted. The use of '-m' requires the use of '-n'.
Manuales
Super Advisor

Re: Trying to reach printers

pint ? ....

okok i am kidding .. you mean píng command ..ok ok let me try.

thanks for your support
Wilfred Chau_1
Respected Contributor

Re: Trying to reach printers

lpstat -p should show the status of the printer. i.e. online or offline.

ping is good.

you can also telnet to the printer port
(hp print server port : 9100 e.g.)

telnet 9100
you should then be presented with a menu and one of the item should show you the status of the printer.
Patrick Wallek
Honored Contributor

Re: Trying to reach printers

>>pint ? ....

>>okok i am kidding .. you mean pà ­ng command
>>..ok ok let me try.

You are correct, I did mean ping.

Although a pint of an adult libation would be nice about now......
Manuales
Super Advisor

Re: Trying to reach printers

it is not working:

$ for a in `cat sidnsnoping.txt `
> do
> /etc/ping -n 2 -t 2 $a
> echo "==="
> done

output:
Usage: ping [-oprv] [-f address-family] [-i address] [-I interval] [-t ttl] hos
t [-n count [-m timeout]]
ping [-oprv] [-f address-family] [-i address] [-I interval] [-t ttl] hos
t packet-size [[-n] count [-m timeout]]

the file sidnsnoping.txt exists correctly ..

what is wrong here?
please help

Patrick Wallek
Honored Contributor

Re: Trying to reach printers

Use '-m' instead of '-t' as I said in my 2nd post.

ping -n 2 -m 2 $a
Matti_Kurkela
Honored Contributor

Re: Trying to reach printers

A simple "man ping" command would have enabled you to find the answer on your own...

ping -n 5 -m 2

will send 5 ping packets, and will wait up to 2 seconds for each ping reply. The total wait time should then be 10 seconds in the worst case (i.e. when the printer is completely not reachable).

If the printer is configured as a "remote" printer to HP-UX, it uses the traditional Unix LPR print protocol. In this case, you can use any tool that can connect to the TCP port 515 on the printer and verify that it works. This test can be done manually using the telnet command targeted to the port 515:

telnet 515 < /dev/null

If the printer is configured as a "network" printer to HP-UX, it is a printer equipped with a HP JetDirect adapter or equivalent functionality. In this case, the port number to test is usually 9100:

telnet 9100 < /dev/null

(The redirection of input from /dev/null prevents the telnet command from waiting forever for input if the test is successful and a connection is actually established.)

MK
MK
Manuales
Super Advisor

Re: Trying to reach printers

It is not working: :(


for a in `cat sidnsnoping.txt `
do
/etc/ping -n 2 -m 2 $a
echo "==="
done

Bill Hassell
Honored Contributor

Re: Trying to reach printers

> It is not working: :(

How do you know it is not working? I don't see any error messages.

This might be more useful:

for PRN in $(cat sidnsnoping.txt)
do
/usr/sbin/ping -n 2 -m 2 $PRN
RTN=$?
[[ $RTN -ne 0 ]] && echo "$PRN = error $RTN"
echo "==="
done


Bill Hassell, sysadmin
Manuales
Super Advisor

Re: Trying to reach printers


$ ./revisa.sh
printer1.myenterprise.com
Usage: ping [-oprv] [-f address-family] [-i address] [-I interval] [-t ttl] hos
t [-n count [-m timeout]]
ping [-oprv] [-f address-family] [-i address] [-I interval] [-t ttl] hos
t packet-size [[-n] count [-m timeout]]
printer1.myenterprise.com = error 1


should i get this?
printer1.myenterprise.com = error 1


does this mean that i do not reach it?
i am on:
HP-UX atlup10 B.11.23

how can i avoid the error of saying that i am not using correctly the command ping??
Steven Schweda
Honored Contributor

Re: Trying to reach printers

> the file sidnsnoping.txt exists correctly ..

My psychic powers are too weak to tell me
what's in it.

cat sidnsnoping.txt

> what is wrong here?

I also can't see exactly what your script is
doing.

cat ./revisa.sh

> Usage: ping [...]

I'd guess that "ping" does not like your
(invisible) command-line options and
parameters.

> how can i avoid the error of saying that i
> am not using correctly the command ping??

Uh, use it correctly? You might start by
trying to see what's happening.

sh -x ./revisa.sh
Bill Hassell
Honored Contributor

Re: Trying to reach printers

> printer1.myenterprise.com
> Usage: ping [-oprv] [-f address-family] [-i address] [-I interval] [-t ttl] host [-n count [-m timeout]]

Pretty obvious problem -- you have specified option(s) that are invalid or have wrong values. This is why the man pages were written. The example above is incorrect. ping requires -n and -m to follow the hostname/IPaddr. This is unlike any other Unix type command and is a common problem with developing ping scripts. The correct script is:

for PRN in $(cat sidnsnoping.txt)
do
/usr/sbin/ping $PRN -n 2 -m 2
RTN=$?
[[ $RTN -ne 0 ]] && echo "$PRN = error $RTN"
echo "==="
done


Bill Hassell, sysadmin
Manuales
Super Advisor

Re: Trying to reach printers

hi!!!! it worked !!!

cat sidnsnoping.txt
printer1.mysite.com
printer2.mysite.com
printer3.mysite.com
printer4.mysite.com
printer5.mysite.com
printer6.mysite.com
printer7.mysite.com

for PRN in $(cat sidnsnoping.txt)
do
echo $PRN
/usr/sbin/ping $PRN -n 2 -m 2
RTN=$?
[[ $RTN -ne 0 ]] && echo "$PRN = error $RTN"
echo "==="
sleep 1
done

thank you so much !!!!
thanks all !!!!