[cs615asa] bwinfo : Bad arguments

Jan Schaumann jschauma at cs.stevens.edu
Sun Apr 19 14:02:37 EDT 2009


Shashwath Veerappa Devaru <sveerapp at stevens.edu> wrote:
 
> When we give a bad arguments like illegal option (say - p) or unknown host
> or a wrong community the error messages are printed out on stdout such as
> 
> ex 1
> $ ./opt -p
> ./opt illegal option -- p

Most getopt implementations should print such errors to stderr:

$ cat /tmp/foo.sh
while getopts abc: f
do
case $f in
        a | b)  flag=$f;;
        c)      carg=$OPTARG;;
esac
done
shift `expr $OPTIND - 1`
$ sh /tmp/foo.sh -d >/dev/null
Illegal option -d
$ sh /tmp/foo.sh -c >/dev/null
No arg for -c option
$

> ex 2
> $ ./opt -t 5 -c cs615 -i eth0 medusa.srci
> getaddrinfo: medusa.srci Name or service not known
> snmpwalk: Unknown host (medusa.srci)

These, too, should go to stderr.  snmpwalk itself will print its errors
to stderr.

$ snmpwalk -c cs615 -v 1 drude >/dev/null
Timeout: No Response from drude
$ 

> ex 3
> $ ./opt -t 5 -c cs615 -i iprb0 drude.cs.stevens.edu
> Timeout: No Response from drude.cs.stevens.edu

The same applies here.

$ snmpwalk -c cs615 -v 1 medusa.srci >/dev/null
snmpwalk: Unknown host
$ 
 
Most unix tools or libraries you might invoke or use should have the
correct behaviour.  That is, if they encounter problems, they will
generate an error message on stderr, not stdout.

-Jan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 186 bytes
Desc: not available
Url : https://lists.stevens.edu/cgi-bin/mailman/private/cs615asa/attachments/20090419/6781ce44/attachment.pgp 


More information about the Cs615asa mailing list