Operating System - HP-UX
1753798 Members
7180 Online
108805 Solutions
New Discussion юеВ

Re: Trying to reach printers

 
SOLVED
Go to solution
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 !!!!