shithub: bin.rc

ref: 4f4b767fae09a76152d777ca1b5372218d6e5ff9
dir: /bin/srvq/

View raw version
#!/bin/rc
rfork e

flagfmt=''; args='name [service [proto]]'
eval `''{aux/getflags $*} || exec aux/usage

if(test $#* -lt 1)
	exec aux/usage
name=$1
service=$2
if(~ $#service 0)
	service='ssh'
proto=$3
if(~ $#proto 0)
	proto='tcp'

rr=`{echo _$service._$proto.$name srv | ndb/dnsquery >[2]/dev/null}
if(echo $rr | grep -s '^!dns:')
	exit NXDOMAIN
echo $rr |
	awk '{printf("%s!%s!%s\n", ENVIRON["proto"], $6, $5)}'