findsock
This commit is contained in:
parent
7c90e8b0ec
commit
f3f6f7006e
|
@ -17,6 +17,7 @@ install: \
|
||||||
$(BINDIR)/psg \
|
$(BINDIR)/psg \
|
||||||
$(BINDIR)/save \
|
$(BINDIR)/save \
|
||||||
$(BINDIR)/savedate \
|
$(BINDIR)/savedate \
|
||||||
|
$(BINDIR)/findsock \
|
||||||
|
|
||||||
fnp: fnp.sh
|
fnp: fnp.sh
|
||||||
fnpa: fnpa.sh
|
fnpa: fnpa.sh
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# Stupid little program to find the socket of stdin of the parent
|
||||||
|
# of the specified process. Normally this is used for the
|
||||||
|
# login shell to determine to which of several virtual hosts the
|
||||||
|
# user connected.
|
||||||
|
|
||||||
|
if [ $# -eq 0 ]
|
||||||
|
then
|
||||||
|
echo "Usage: $0 <pid of login shell>" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
pid=$1
|
||||||
|
|
||||||
|
ppid=`ps -ef | awk -v pid=$pid '$2 == pid { print $3 }'`
|
||||||
|
|
||||||
|
sock=`lsof -p $ppid 2>/dev/null | awk '$4 == "0u" && $5 == "inet" { print $9 }'`
|
||||||
|
echo $sock
|
Loading…
Reference in New Issue