#!/bin/sh

# Copyright 2007 Ronny Aasen <ronny@skolelinux.no>
# Distributed under the terms of the GNU General Public License version 2 or any later version.

# queries the nbd-clients and reports what source ports it uses to stdout. 
# should usually be run from an inetd. unfortunatly because of lsof it needs to run as root

PATH=/bin:/usr/bin
export PATH

for pid in $(pidof nbd-client) ; do
   port=$(lsof -P -p $pid | grep 9210 | cut -d":" -f2 | cut -d"-" -f1)
   echo $port
done



